<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span>  * Copyright (C) 2008, 2009 Mihai Şucan
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * This file is part of libmacrame.
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * Libmacrame is free software: you can redistribute it and/or modify
<span class='line'>  7</span>  * it under the terms of the GNU General Public License as published by
<span class='line'>  8</span>  * the Free Software Foundation, either version 3 of the License, or
<span class='line'>  9</span>  * (at your option) any later version.
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * Libmacrame is distributed in the hope that it will be useful,
<span class='line'> 12</span>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class='line'> 13</span>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class='line'> 14</span>  * GNU General Public License for more details.
<span class='line'> 15</span>  *
<span class='line'> 16</span>  * You should have received a copy of the GNU General Public License
<span class='line'> 17</span>  * along with Libmacrame.  If not, see &lt;http://www.gnu.org/licenses/>.
<span class='line'> 18</span>  *
<span class='line'> 19</span>  * $URL: http://code.google.com/p/libmacrame $
<span class='line'> 20</span>  * $Date: 2009-04-21 13:37:06 +0300 $
<span class='line'> 21</span>  *
<span class='line'> 22</span>  */</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="COMM">/**
<span class='line'> 25</span>  * @author &lt;a lang="ro" href="http://www.robodesign.ro/mihai">Mihai Şucan&lt;/a>
<span class='line'> 26</span>  * @version pre-alpha
<span class='line'> 27</span>  * @requires core.js
<span class='line'> 28</span>  * @requires core-js.js
<span class='line'> 29</span>  *
<span class='line'> 30</span>  * @fileOverview This is a plugin for libmacrame which adds important methods 
<span class='line'> 31</span>  * for manipulation the DOM.
<span class='line'> 32</span>  */</span><span class="WHIT">
<span class='line'> 33</span> 
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="COMM">// We will use $ to refer to libmacrame in this plugin.</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">libmacrame</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> 
<span class='line'> 39</span> </span><span class="COMM">/*
<span class='line'> 40</span>  * If extend_objects is set to true:
<span class='line'> 41</span>  * the script will add during runtime new methods and properties to the DOM 
<span class='line'> 42</span>  * objects: Node, Element, Text, NodeList, HTMLCollection, NamedNodeMap, 
<span class='line'> 43</span>  * HTMLElement, HTMLLinkElement, HTMLAnchorElement, HTMLAreaElement, Event, 
<span class='line'> 44</span>  * EventTarget, KeyboardEvent.
<span class='line'> 45</span>  *
<span class='line'> 46</span>  * Note that some of the implementations of the new methods rely on the fact 
<span class='line'> 47</span>  * that this setting is set to true.
<span class='line'> 48</span>  */</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">extend_objects</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> 
<span class='line'> 51</span> </span><span class="COMM">// We store all the DOM-related methods in $.dom, for quick reuse in any case </span><span class="WHIT">
<span class='line'> 52</span> </span><span class="COMM">// where they are needed.</span><span class="WHIT">
<span class='line'> 53</span> 
<span class='line'> 54</span> </span><span class="COMM">/**
<span class='line'> 55</span>  * Holds the DOM-related methods.
<span class='line'> 56</span>  *
<span class='line'> 57</span>  * &lt;p>This plugin extends the global DOM objects, like Node, Element and 
<span class='line'> 58</span>  * NodeList.
<span class='line'> 59</span>  *
<span class='line'> 60</span>  * &lt;p>The {@link $.dom.NodeList} methods are also used for extending the 
<span class='line'> 61</span>  * HTMLCollection object prototype, since the two interfaces serve similar 
<span class='line'> 62</span>  * purpose. However, due to &lt;a 
<span class='line'> 63</span>  * href="https://bugzilla.mozilla.org/show_bug.cgi?id=300519">bug 300519&lt;/a>, in 
<span class='line'> 64</span>  * Gecko any changes to the HTMLCollection.prototype do not yield the expected 
<span class='line'> 65</span>  * results. As such, a work-around needs to be implemented. (TODO)
<span class='line'> 66</span>  *
<span class='line'> 67</span>  * &lt;p>The new methods implement common functionality needed when working with 
<span class='line'> 68</span>  * the DOM.
<span class='line'> 69</span>  *
<span class='line'> 70</span>  * @namespace Holds the DOM-related methods.
<span class='line'> 71</span>  */</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="NAME">$.dom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> 
<span class='line'> 74</span> </span><span class="COMM">/**
<span class='line'> 75</span>  * Holds the DOM Node methods.
<span class='line'> 76</span>  *
<span class='line'> 77</span>  * &lt;p>By default, the global &lt;var>Node.prototype&lt;/var> object is extended to 
<span class='line'> 78</span>  * contain all the methods defined in this namespace.
<span class='line'> 79</span>  *
<span class='line'> 80</span>  * &lt;p>All of these methods use their &lt;var>this&lt;/var> object. As such, you need 
<span class='line'> 81</span>  * to pass the correct &lt;var>this&lt;/var> object.
<span class='line'> 82</span>  *
<span class='line'> 83</span>  * &lt;p>In the examples provided for each method we will assume that the objects 
<span class='line'> 84</span>  * defined are already extended. Thus code like 
<span class='line'> 85</span>  * &lt;code>&lt;var>node&lt;/var>.prependChild(&lt;var>child&lt;/var>)&lt;/code> can be written 
<span class='line'> 86</span>  * directly. Such code can be read as "add the node &lt;var>child&lt;/var> as a new 
<span class='line'> 87</span>  * child to the &lt;var>node&lt;/var> node, making sure it's the first child".
<span class='line'> 88</span>  *
<span class='line'> 89</span>  * @namespace Holds the DOM Node methods.
<span class='line'> 90</span>  *
<span class='line'> 91</span>  * @see $.dom
<span class='line'> 92</span>  * @see $.dom.Element
<span class='line'> 93</span>  * @see $.dom.NodeList
<span class='line'> 94</span>  */</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="NAME">$.dom.Node</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 97</span>    * Insert a new node as the first child to the current node.
<span class='line'> 98</span>    *
<span class='line'> 99</span>    * @example
<span class='line'>100</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('div');
<span class='line'>101</span>    * // Insert the element as the first child to the document.body.
<span class='line'>102</span>    * document.body.prependChild(&lt;var>elem&lt;/var>);&lt;/code>
<span class='line'>103</span>    *
<span class='line'>104</span>    * @param {Node} child The node to prepend as a child.
<span class='line'>105</span>    *
<span class='line'>106</span>    * @throws {TypeError} If &lt;var>child&lt;/var> is not an instance of Node.
<span class='line'>107</span>    *
<span class='line'>108</span>    * @returns {Node} The prepended child node.
<span class='line'>109</span>    *
<span class='line'>110</span>    * @see $.dom.NodeList.prependChild
<span class='line'>111</span>    * @see $.dom.NodeList.appendChild
<span class='line'>112</span>    */</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">  </span><span class="NAME">prependChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">child</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>117</span> 
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.insertBefore</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.firstChild</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>120</span> 
<span class='line'>121</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>122</span>    * Remove the first child from the current node.
<span class='line'>123</span>    *
<span class='line'>124</span>    * @example
<span class='line'>125</span>    * // Remove the first child from the document.body.
<span class='line'>126</span>    * &lt;code>document.body.removeFirstChild();&lt;/code>
<span class='line'>127</span>    *
<span class='line'>128</span>    * @returns {Node|null} The removed child node, or null if nothing was 
<span class='line'>129</span>    * removed.
<span class='line'>130</span>    *
<span class='line'>131</span>    * @see $.dom.Node.removeLastChild
<span class='line'>132</span>    * @see $.dom.NodeList.removeFirstChild
<span class='line'>133</span>    * @see $.dom.NodeList.removeLastChild
<span class='line'>134</span>    */</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">  </span><span class="NAME">removeFirstChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.firstChild</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this.removeChild</span><span class="PUNC">(</span><span class="NAME">this.firstChild</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>138</span> 
<span class='line'>139</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>140</span>    * Remove the last child from the current node.
<span class='line'>141</span>    *
<span class='line'>142</span>    * @example
<span class='line'>143</span>    * // Remove the last child from the document.body.
<span class='line'>144</span>    * &lt;code>document.body.removeLastChild();&lt;/code>
<span class='line'>145</span>    *
<span class='line'>146</span>    * @returns {Node|null} The removed child node, or null if nothing was 
<span class='line'>147</span>    * removed.
<span class='line'>148</span>    *
<span class='line'>149</span>    * @see $.dom.Node.removeFirstChild
<span class='line'>150</span>    * @see $.dom.NodeList.removeFirstChild
<span class='line'>151</span>    * @see $.dom.NodeList.removeLastChild
<span class='line'>152</span>    */</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">  </span><span class="NAME">removeLastChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.lastChild</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this.removeChild</span><span class="PUNC">(</span><span class="NAME">this.lastChild</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>156</span> 
<span class='line'>157</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>158</span>    * Append the current node to the &lt;var>target&lt;/var> node.
<span class='line'>159</span>    *
<span class='line'>160</span>    * &lt;p>The current node is added to the list of children of the 
<span class='line'>161</span>    * &lt;var>target&lt;/var> node, becoming the last child.
<span class='line'>162</span>    *
<span class='line'>163</span>    * @example
<span class='line'>164</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('div');
<span class='line'>165</span>    * // Add the element to the body.
<span class='line'>166</span>    * &lt;var>elem&lt;/var>.appendTo(document.body);&lt;/code>
<span class='line'>167</span>    *
<span class='line'>168</span>    * @param {Node} target The target node where to append the current node.
<span class='line'>169</span>    *
<span class='line'>170</span>    * @throws {TypeError} If &lt;var>target&lt;/var> is not an instance of Node.
<span class='line'>171</span>    *
<span class='line'>172</span>    * @returns {Node} The node that was appended.
<span class='line'>173</span>    *
<span class='line'>174</span>    * @see $.dom.Node.prependTo
<span class='line'>175</span>    * @see $.dom.NodeList.prependTo
<span class='line'>176</span>    * @see $.dom.NodeList.appendTo
<span class='line'>177</span>    */</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">  </span><span class="NAME">appendTo</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">target</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>182</span> 
<span class='line'>183</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">target.appendChild</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>185</span> 
<span class='line'>186</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>187</span>    * Prepend the current node to the &lt;var>target&lt;/var> node.
<span class='line'>188</span>    *
<span class='line'>189</span>    * &lt;p>The current node is added to the list of children of the 
<span class='line'>190</span>    * &lt;var>target&lt;/var> node, becoming the first child.
<span class='line'>191</span>    *
<span class='line'>192</span>    * @example
<span class='line'>193</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('div');
<span class='line'>194</span>    * // Add the element to the body.
<span class='line'>195</span>    * &lt;var>elem&lt;/var>.prependTo(document.body);&lt;/code>
<span class='line'>196</span>    *
<span class='line'>197</span>    * @param {Node} target The target node where to prepend the current node.
<span class='line'>198</span>    *
<span class='line'>199</span>    * @throws {TypeError} If &lt;var>target&lt;/var> is not an instance of Node.
<span class='line'>200</span>    *
<span class='line'>201</span>    * @returns {Node} The node that was prepended.
<span class='line'>202</span>    *
<span class='line'>203</span>    * @see $.dom.Node.appendTo
<span class='line'>204</span>    * @see $.dom.NodeList.prependTo
<span class='line'>205</span>    * @see $.dom.NodeList.appendTo
<span class='line'>206</span>    */</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">  </span><span class="NAME">prependTo</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">target</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>211</span> 
<span class='line'>212</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">target.insertBefore</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target.firstChild</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>214</span> 
<span class='line'>215</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>216</span>    * Insert the specified node after a reference node to the current node.
<span class='line'>217</span>    * 
<span class='line'>218</span>    * &lt;p>The &lt;var>new_node&lt;/var> will be added as a child of the current node, 
<span class='line'>219</span>    * after the &lt;var>ref_node&lt;/var>.
<span class='line'>220</span>    *
<span class='line'>221</span>    * &lt;p>This method works like the native &lt;code>node.insertBefore()&lt;/code> 
<span class='line'>222</span>    * method, which is actually used in the implementation.
<span class='line'>223</span>    *
<span class='line'>224</span>    * @example
<span class='line'>225</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('div'),
<span class='line'>226</span>    *     &lt;var>ref&lt;/var> = $('#foo');
<span class='line'>227</span>    * document.body.insertAfter(&lt;var>elem&lt;/var>, &lt;var>ref&lt;/var>);&lt;/code>
<span class='line'>228</span>    *
<span class='line'>229</span>    * @param {Node} new_node The new node to insert as a child.
<span class='line'>230</span>    * @param {Node} ref_node The reference child node after which you want to 
<span class='line'>231</span>    * insert the given new child node. If this argument is null, the new node is 
<span class='line'>232</span>    * simply appended as a child, becoming the last in the list of children.
<span class='line'>233</span>    *
<span class='line'>234</span>    * @throws {TypeError} If &lt;var>new_node&lt;/var> is not an instance of Node.
<span class='line'>235</span>    *
<span class='line'>236</span>    * @returns {Node} The node that was inserted.
<span class='line'>237</span>    *
<span class='line'>238</span>    * @see $.dom.NodeList.insertAfter
<span class='line'>239</span>    * @see $.dom.NodeList.insertBefore
<span class='line'>240</span>    */</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">  </span><span class="NAME">insertAfter</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">new_node</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ref_node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">new_node</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>245</span> 
<span class='line'>246</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">before</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ref_node</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">ref_node.nextSibling</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.insertBefore</span><span class="PUNC">(</span><span class="NAME">new_node</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">before</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>249</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> 
<span class='line'>251</span> </span><span class="COMM">/**
<span class='line'>252</span>  * Holds the DOM Element methods.
<span class='line'>253</span>  *
<span class='line'>254</span>  * &lt;p>By default, the global &lt;var>Element.prototype&lt;/var> object is extended to 
<span class='line'>255</span>  * contain all the methods defined in this namespace.
<span class='line'>256</span>  *
<span class='line'>257</span>  * &lt;p>The global &lt;var>Text.prototype&lt;/var> and &lt;var>Comment.prototype&lt;/var> DOM 
<span class='line'>258</span>  * objects are also extended. However, these two prototypes are only extended to 
<span class='line'>259</span>  * contain the new {@link $.dom.Element.wrap} method.
<span class='line'>260</span>  *
<span class='line'>261</span>  * &lt;p>All of these methods use their &lt;var>this&lt;/var> object. As such, you need 
<span class='line'>262</span>  * to pass the correct &lt;var>this&lt;/var> object.
<span class='line'>263</span>  *
<span class='line'>264</span>  * &lt;p>In the examples provided for each method we will assume that the objects 
<span class='line'>265</span>  * defined are already extended. Thus code like 
<span class='line'>266</span>  * &lt;code>&lt;var>element&lt;/var>.wrap('&lt;p&gt;')&lt;/code> can be written directly.
<span class='line'>267</span>  *
<span class='line'>268</span>  * @namespace Holds the DOM Element methods.
<span class='line'>269</span>  *
<span class='line'>270</span>  * @see $.dom.Node
<span class='line'>271</span>  * @see $.dom.NodeList
<span class='line'>272</span>  */</span><span class="WHIT">
<span class='line'>273</span> </span><span class="NAME">$.dom.Element</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>275</span>    * Wrap the element inside a given wrapper.
<span class='line'>276</span>    *
<span class='line'>277</span>    * @example
<span class='line'>278</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('p');
<span class='line'>279</span>    *
<span class='line'>280</span>    * document.body.appendChild(&lt;var>elem&lt;/var>);&lt;/code>
<span class='line'>281</span>    *
<span class='line'>282</span>    * // Now the body would serialize to something like:
<span class='line'>283</span>    * // &lt;body&gt;&lt;p&gt;&lt;/p&gt;&lt;/body&gt;
<span class='line'>284</span>    *
<span class='line'>285</span>    * &lt;code>var &lt;var>result&lt;/var> = &lt;var>elem&lt;/var>.wrap('&lt;div&gt;');&lt;/code>
<span class='line'>286</span>    *
<span class='line'>287</span>    * // Now &lt;var>result&lt;/var> = the &lt;div&gt; node.
<span class='line'>288</span>    * // The body would serialize to something like:
<span class='line'>289</span>    * // &lt;body&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/body&gt;
<span class='line'>290</span>    *
<span class='line'>291</span>    * @example
<span class='line'>292</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('p');
<span class='line'>293</span>    *
<span class='line'>294</span>    * document.body.appendChild(&lt;var>elem&lt;/var>);&lt;/code>
<span class='line'>295</span>    *
<span class='line'>296</span>    * // Now the body would serialize to something like:
<span class='line'>297</span>    * // &lt;body&gt;&lt;p&gt;&lt;/p&gt;&lt;/body&gt;
<span class='line'>298</span>    *
<span class='line'>299</span>    * &lt;code>var &lt;var>wrapper&lt;/var> = '&lt;div id=&#34;test1&#34;&gt;' +
<span class='line'>300</span>    *               '&lt;div id=&#34;test2&#34;&gt;';
<span class='line'>301</span>    *
<span class='line'>302</span>    * var &lt;var>result&lt;/var> = &lt;var>elem&lt;/var>.wrap(&lt;var>wrapper&lt;/var>);&lt;/code>
<span class='line'>303</span>    *
<span class='line'>304</span>    * // Now &lt;var>result&lt;/var> = the #test1 node.
<span class='line'>305</span>    * // The body would serialize to something like:
<span class='line'>306</span>    * // &lt;body&gt;&lt;div id=&#34;test1&#34;&gt;&lt;div id=&#34;test2&#34;&gt;&lt;p&gt;
<span class='line'>307</span>    * // &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;
<span class='line'>308</span>    *
<span class='line'>309</span>    * @example
<span class='line'>310</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('p');
<span class='line'>311</span>    *
<span class='line'>312</span>    * document.body.appendChild(&lt;var>elem&lt;/var>);&lt;/code>
<span class='line'>313</span>    *
<span class='line'>314</span>    * // Now the body would serialize to something like:
<span class='line'>315</span>    * // &lt;body&gt;&lt;p&gt;&lt;/p&gt;&lt;/body&gt;
<span class='line'>316</span>    *
<span class='line'>317</span>    * &lt;code>var &lt;var>wrapper1&lt;/var> = document.createElement('div'),
<span class='line'>318</span>    *     &lt;var>wrapper2&lt;/var> = document.createElement('div');
<span class='line'>319</span>    *
<span class='line'>320</span>    * &lt;var>wrapper1&lt;/var>.id = 'test1';
<span class='line'>321</span>    * &lt;var>wrapper1&lt;/var>.appendChild(&lt;var>wrapper2&lt;/var>);
<span class='line'>322</span>    * &lt;var>wrapper2&lt;/var>.id = 'test2';
<span class='line'>323</span>    *
<span class='line'>324</span>    * var &lt;var>result&lt;/var> = &lt;var>elem&lt;/var>.wrap(&lt;var>wrapper1&lt;/var>);&lt;/code>
<span class='line'>325</span>    *
<span class='line'>326</span>    * // Now &lt;code>&lt;var>result&lt;/var> = &lt;var>wrapper1&lt;/var>&lt;/code>.
<span class='line'>327</span>    * // The body would serialize to something like:
<span class='line'>328</span>    * // &lt;body&gt;&lt;div id=&#34;test1&#34;&gt;&lt;div id=&#34;test2&#34;&gt;&lt;p&gt;
<span class='line'>329</span>    * // &lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/body&gt;
<span class='line'>330</span>    *
<span class='line'>331</span>    * @param {Element|String} wrapper The element or the string to use for 
<span class='line'>332</span>    * wrapping the current element.
<span class='line'>333</span>    *
<span class='line'>334</span>    * &lt;p>If the wrapper is an element, then it is be used as-is for wrapping.
<span class='line'>335</span>    *
<span class='line'>336</span>    * &lt;p>If the wrapper is a string, it is be parsed as HTML code. Then, the 
<span class='line'>337</span>    * firstElementChild of the DOM tree generated by the string becomes the 
<span class='line'>338</span>    * wrapper.
<span class='line'>339</span>    *
<span class='line'>340</span>    * &lt;p>For both cases the determined wrapper gets added to the parent node of 
<span class='line'>341</span>    * the current element (the &lt;var>this&lt;/var> object), if it's available.
<span class='line'>342</span>    *
<span class='line'>343</span>    * &lt;p>The deepest child element of the wrapper is searched, so that the 
<span class='line'>344</span>    * current element will be appended into it.
<span class='line'>345</span>    *
<span class='line'>346</span>    * @throws {TypeError} If the current node is not an element/text/comment 
<span class='line'>347</span>    * node. This method cannot wrap other kinds of objects.
<span class='line'>348</span>    *
<span class='line'>349</span>    * @throws {ReferenceError} If the wrapper is a string and the current element 
<span class='line'>350</span>    * has no owner document.
<span class='line'>351</span>    *
<span class='line'>352</span>    * @throws {ReferenceError} If the wrapper is a string with no elements in it.
<span class='line'>353</span>    *
<span class='line'>354</span>    * @returns {Element} The wrapper element.
<span class='line'>355</span>    *
<span class='line'>356</span>    * @see $.dom.Element.wrapInner
<span class='line'>357</span>    */</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">  </span><span class="NAME">wrap</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> 
<span class='line'>360</span>         </span><span class="NAME">Node.TEXT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.COMMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'This node must be an DOM element/text/comment node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>363</span> 
<span class='line'>364</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>365</span> 
<span class='line'>366</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">doc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.ownerDocument</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">doc.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.DOCUMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ReferenceError</span><span class="PUNC">(</span><span class="STRN">'This node does not have an owner document. You cannot wrap it into a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>371</span> 
<span class='line'>372</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">div</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">doc.createElement</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">      </span><span class="NAME">div.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">      </span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">div.firstElementChild</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ReferenceError</span><span class="PUNC">(</span><span class="STRN">'The provided string does not contain any element tag.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>378</span> 
<span class='line'>379</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">      </span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM element or a string.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>384</span> 
<span class='line'>385</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.parentNode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">      </span><span class="NAME">this.parentNode.insertBefore</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>388</span> 
<span class='line'>389</span> </span><span class="WHIT">    </span><span class="COMM">// Find the deepest child element.</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">first.firstElementChild</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">      </span><span class="NAME">first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">first.firstElementChild</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>394</span> 
<span class='line'>395</span> </span><span class="WHIT">    </span><span class="NAME">first.appendChild</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>396</span> 
<span class='line'>397</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>399</span> 
<span class='line'>400</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>401</span>    * Wrap all the child nodes of the current element.
<span class='line'>402</span>    *
<span class='line'>403</span>    * &lt;p>The &lt;var>wrapper&lt;/var> argument is the same as for {@link 
<span class='line'>404</span>    * $.dom.Element.wrap}.
<span class='line'>405</span>    *
<span class='line'>406</span>    * @example
<span class='line'>407</span>    * &lt;code>var &lt;var>child1&lt;/var> = document.createElement('p'),
<span class='line'>408</span>    *     &lt;var>child2&lt;/var> = document.createElement('p');
<span class='line'>409</span>    *
<span class='line'>410</span>    * &lt;var>child1&lt;/var>.id = 'child1';
<span class='line'>411</span>    * &lt;var>child2&lt;/var>.id = 'child2';
<span class='line'>412</span>    *
<span class='line'>413</span>    * document.body.appendChild(&lt;var>child1&lt;/var>);
<span class='line'>414</span>    * document.body.appendChild(&lt;var>child2&lt;/var>);&lt;/code>
<span class='line'>415</span>    * // Now the body contains the two children.
<span class='line'>416</span>    *
<span class='line'>417</span>    * &lt;code>var result = document.body.wrapInner('&lt;div&gt;');&lt;/code>
<span class='line'>418</span>    * // Now &lt;var>result&lt;/var> is a NodeList containing &lt;var>child1&lt;/var>
<span class='line'>419</span>    * // and &lt;var>child2&lt;/var>.
<span class='line'>420</span>    *
<span class='line'>421</span>    * // The body would serialize to something like:
<span class='line'>422</span>    * // &lt;body&gt;&lt;div&gt;&lt;p id=&#34;child1&#34;&gt;&lt;/p&gt;
<span class='line'>423</span>    * // &lt;p id=&#34;chil2&#34;&gt;&lt;/p&gt;&lt;/div&gt;&lt;/body&gt;
<span class='line'>424</span>    * 
<span class='line'>425</span>    * @param {Element|String} wrapper The element or the string to use for 
<span class='line'>426</span>    * wrapping the child nodes of the current element.
<span class='line'>427</span>    *
<span class='line'>428</span>    * @throws {TypeError} If the current node is not an element node. This method 
<span class='line'>429</span>    * cannot wrap other kinds of objects.
<span class='line'>430</span>    *
<span class='line'>431</span>    * @throws {ReferenceError} If the wrapper is a string and the current element 
<span class='line'>432</span>    * has no owner document.
<span class='line'>433</span>    *
<span class='line'>434</span>    * @throws {ReferenceError} If the wrapper is a string with no elements in it.
<span class='line'>435</span>    *
<span class='line'>436</span>    * @returns {NodeList} The list of wrapped child nodes.
<span class='line'>437</span>    * (&lt;code>&lt;var>wrapper&lt;/var>.childNodes&lt;/code>)
<span class='line'>438</span>    *
<span class='line'>439</span>    * @see $.dom.Element.wrap
<span class='line'>440</span>    */</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT">  </span><span class="NAME">wrapInner</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'This node must be an DOM element.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>445</span> 
<span class='line'>446</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.hasChildNodes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$.dom.NodeList.wrapAll.call</span><span class="PUNC">(</span><span class="NAME">this.childNodes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>452</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>453</span> 
<span class='line'>454</span> </span><span class="COMM">// Make sure we can wrap text and comment nodes as well.</span><span class="WHIT">
<span class='line'>455</span> </span><span class="NAME">$.dom.Text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.Comment</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">  </span><span class="NAME">wrap</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.Element.wrap</span><span class="WHIT">
<span class='line'>457</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>458</span> 
<span class='line'>459</span> </span><span class="COMM">/**
<span class='line'>460</span>  * Holds the DOM NodeList methods, which allow the manipulation of multiple 
<span class='line'>461</span>  * nodes in a single step.
<span class='line'>462</span>  *
<span class='line'>463</span>  * &lt;p>By default, the global &lt;var>NodeList.prototype&lt;/var> object is extended to 
<span class='line'>464</span>  * contain all the methods defined in this namespace.
<span class='line'>465</span>  *
<span class='line'>466</span>  * &lt;p>These methods are also used for extending the global 
<span class='line'>467</span>  * &lt;var>HTMLCollection.prototype&lt;/var> object.
<span class='line'>468</span>  *
<span class='line'>469</span>  * &lt;p>All of these methods use their &lt;var>this&lt;/var> object. As such, you need 
<span class='line'>470</span>  * to pass the correct &lt;var>this&lt;/var> object.
<span class='line'>471</span>  *
<span class='line'>472</span>  * &lt;p>In the examples provided for each method we will assume that the objects 
<span class='line'>473</span>  * defined are already extended. Thus code like 
<span class='line'>474</span>  * &lt;code>&lt;var>element.childNodes&lt;/var>.wrap('&lt;p&gt;')&lt;/code> can be written 
<span class='line'>475</span>  * directly.
<span class='line'>476</span>  *
<span class='line'>477</span>  * @example
<span class='line'>478</span>  * // DOM elements have the &lt;var>.childNodes&lt;/var> property object which holds
<span class='line'>479</span>  * // the list of child nodes. This object is an instance of NodeList. By
<span class='line'>480</span>  * // extending the &lt;var>NodeList.prototype&lt;/var> you can do the following:
<span class='line'>481</span>  *
<span class='line'>482</span>  * var &lt;var>new_child&lt;/var> = document.createElement('p');
<span class='line'>483</span>  * document.body.childNodes.appendChild(&lt;var>new_child&lt;/var>);
<span class='line'>484</span>  *
<span class='line'>485</span>  * // The above code appends a clone of the &lt;var>new_child&lt;/var> into each child
<span class='line'>486</span>  * // node of the document body.
<span class='line'>487</span>  *
<span class='line'>488</span>  * // As expected, you can use any of the methods defined in this namespace.
<span class='line'>489</span>  *
<span class='line'>490</span>  * @namespace Holds the DOM NodeList methods, which allow the manipulation of 
<span class='line'>491</span>  * multiple nodes in a single step.
<span class='line'>492</span>  *
<span class='line'>493</span>  * @requires $.js.Array
<span class='line'>494</span>  *
<span class='line'>495</span>  * @see $.dom.Node
<span class='line'>496</span>  * @see $.dom.Element
<span class='line'>497</span>  */</span><span class="WHIT">
<span class='line'>498</span> </span><span class="NAME">$.dom.NodeList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>500</span>    * Convert the current NodeList to an array.
<span class='line'>501</span>    *
<span class='line'>502</span>    * &lt;p>Each NodeList item becomes an array element. The array has the same 
<span class='line'>503</span>    * length as the NodeList object.
<span class='line'>504</span>    *
<span class='line'>505</span>    * &lt;p>The returned array is a static list. If the NodeList changes, the array 
<span class='line'>506</span>    * does not.
<span class='line'>507</span>    *
<span class='line'>508</span>    * @returns {Array} The current NodeList converted to an array, having the 
<span class='line'>509</span>    * same length.
<span class='line'>510</span>    *
<span class='line'>511</span>    * @see $.js.Array
<span class='line'>512</span>    */</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">  </span><span class="NAME">toArray</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>516</span> 
<span class='line'>517</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>518</span> </span><span class="WHIT">      </span><span class="NAME">resArr</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>519</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>520</span> 
<span class='line'>521</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>523</span> 
<span class='line'>524</span> </span><span class="WHIT">  </span><span class="COMM">// Array methods</span><span class="WHIT">
<span class='line'>525</span> 
<span class='line'>526</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>527</span>    * Extract a section of the current NodeList and return it.
<span class='line'>528</span>    *
<span class='line'>529</span>    * @function
<span class='line'>530</span>    *
<span class='line'>531</span>    * @param {Number} begin
<span class='line'>532</span>    *
<span class='line'>533</span>    * @param {Number} [end=this.length]
<span class='line'>534</span>    *
<span class='line'>535</span>    * @throws {TypeError} If &lt;var>begin&lt;/var> is not a number, or if it is 
<span class='line'>536</span>    * a negative number.
<span class='line'>537</span>    *
<span class='line'>538</span>    * @throws {TypeError} If &lt;var>end&lt;/var> is provided, but it is not a number.
<span class='line'>539</span>    *
<span class='line'>540</span>    * @returns {Array} The new array returned contains all the nodes starting 
<span class='line'>541</span>    * from the &lt;var>begin&lt;/var> index (including it) up to the &lt;var>end&lt;/var> 
<span class='line'>542</span>    * index (excluding it).
<span class='line'>543</span>    *
<span class='line'>544</span>    * @requires $.js.Array.slice
<span class='line'>545</span>    * @see $.js.Array.slice for more details and examples
<span class='line'>546</span>    */</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT">  </span><span class="NAME">slice</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.slice</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>548</span> 
<span class='line'>549</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>550</span>    * Filter the current NodeList using the &lt;var>callback&lt;/var> function.
<span class='line'>551</span>    *
<span class='line'>552</span>    * @function
<span class='line'>553</span>    *
<span class='line'>554</span>    * @param {Function} callback
<span class='line'>555</span>    *
<span class='line'>556</span>    * @param {Object} [thisObject]
<span class='line'>557</span>    *
<span class='line'>558</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>559</span>    *
<span class='line'>560</span>    * @returns {Array} The new array contains the nodes for which the 
<span class='line'>561</span>    * &lt;var>callback&lt;/var> function returned true.
<span class='line'>562</span>    *
<span class='line'>563</span>    * @requires $.js.Array.filter
<span class='line'>564</span>    * @see $.js.Array.filter for more details and examples
<span class='line'>565</span>    */</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">  </span><span class="NAME">filter</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.filter</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>567</span> 
<span class='line'>568</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>569</span>    * Execute the &lt;var>callback&lt;/var> function for each node in the current 
<span class='line'>570</span>    * NodeList.
<span class='line'>571</span>    *
<span class='line'>572</span>    * @function
<span class='line'>573</span>    *
<span class='line'>574</span>    * @param {Function} callback
<span class='line'>575</span>    *
<span class='line'>576</span>    * @param {Object} [thisObject]
<span class='line'>577</span>    *
<span class='line'>578</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>579</span>    *
<span class='line'>580</span>    * @requires $.js.Array.forEach
<span class='line'>581</span>    * @see $.js.Array.forEach for more details and examples
<span class='line'>582</span>    */</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT">  </span><span class="NAME">forEach</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.forEach</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>584</span> 
<span class='line'>585</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>586</span>    * Check if the &lt;var>callback&lt;/var> function returns true for every node in 
<span class='line'>587</span>    * the current NodeList.
<span class='line'>588</span>    *
<span class='line'>589</span>    * @function
<span class='line'>590</span>    *
<span class='line'>591</span>    * @param {Function} callback
<span class='line'>592</span>    *
<span class='line'>593</span>    * @param {Object} [thisObject]
<span class='line'>594</span>    *
<span class='line'>595</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>596</span>    *
<span class='line'>597</span>    * @returns {Boolean} False is returned if the &lt;var>callback&lt;/var> returns 
<span class='line'>598</span>    * false once.  Otherwise, this method returns true.
<span class='line'>599</span>    *
<span class='line'>600</span>    * @requires $.js.Array.every
<span class='line'>601</span>    * @see $.js.Array.every for more details and examples
<span class='line'>602</span>    */</span><span class="WHIT">
<span class='line'>603</span> </span><span class="WHIT">  </span><span class="NAME">every</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.every</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>604</span> 
<span class='line'>605</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>606</span>    * Check if the &lt;var>callback&lt;/var> function returns true for at least one 
<span class='line'>607</span>    * node in the current NodeList.
<span class='line'>608</span>    *
<span class='line'>609</span>    * @function
<span class='line'>610</span>    *
<span class='line'>611</span>    * @param {Function} callback
<span class='line'>612</span>    *
<span class='line'>613</span>    * @param {Object} [thisObject]
<span class='line'>614</span>    *
<span class='line'>615</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>616</span>    *
<span class='line'>617</span>    * @returns {Boolean} True is returned if the &lt;var>callback&lt;/var> returns true 
<span class='line'>618</span>    * once. Otherwise, this method returns false.
<span class='line'>619</span>    *
<span class='line'>620</span>    * @requires $.js.Array.some
<span class='line'>621</span>    * @see $.js.Array.some for more details and examples
<span class='line'>622</span>    */</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT">  </span><span class="NAME">some</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.some</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>624</span> 
<span class='line'>625</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>626</span>    * Create a new array with the same length as the current NodeList using the 
<span class='line'>627</span>    * values returned by the &lt;var>callback&lt;/var> function.
<span class='line'>628</span>    *
<span class='line'>629</span>    * @function
<span class='line'>630</span>    *
<span class='line'>631</span>    * @param {Function} callback
<span class='line'>632</span>    *
<span class='line'>633</span>    * @param {Object} [thisObject]
<span class='line'>634</span>    *
<span class='line'>635</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>636</span>    *
<span class='line'>637</span>    * @returns {Boolean} The new array has the same length, but the values are 
<span class='line'>638</span>    * those returned by the &lt;var>callback&lt;/var> function.
<span class='line'>639</span>    *
<span class='line'>640</span>    * @requires $.js.Array.map
<span class='line'>641</span>    * @see $.js.Array.map for more details and examples
<span class='line'>642</span>    */</span><span class="WHIT">
<span class='line'>643</span> </span><span class="WHIT">  </span><span class="NAME">map</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.map</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>644</span> 
<span class='line'>645</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>646</span>    * Apply the &lt;var>callback&lt;/var> function to two values in the current 
<span class='line'>647</span>    * NodeList, from left to right, simultaneously, for the purpose of reducing 
<span class='line'>648</span>    * the NodeList to a single value.
<span class='line'>649</span>    *
<span class='line'>650</span>    * @function
<span class='line'>651</span>    *
<span class='line'>652</span>    * @param {Function} callback
<span class='line'>653</span>    *
<span class='line'>654</span>    * @param [initialValue]
<span class='line'>655</span>    *
<span class='line'>656</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>657</span>    *
<span class='line'>658</span>    * @returns The result of the last &lt;var>callback&lt;/var> function invocation.
<span class='line'>659</span>    *
<span class='line'>660</span>    * @requires $.js.Array.reduce
<span class='line'>661</span>    * @see $.js.Array.reduce for more details and examples
<span class='line'>662</span>    * @see $.dom.NodeList.reduceRight
<span class='line'>663</span>    */</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">  </span><span class="NAME">reduce</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.reduce</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>665</span> 
<span class='line'>666</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>667</span>    * Apply the &lt;var>callback&lt;/var> function to two values from the current 
<span class='line'>668</span>    * NodeList, from right to left, simultaneously, for the purpose of reducing 
<span class='line'>669</span>    * the NodeList to a single value.
<span class='line'>670</span>    *
<span class='line'>671</span>    * @function
<span class='line'>672</span>    *
<span class='line'>673</span>    * @param {Function} callback
<span class='line'>674</span>    *
<span class='line'>675</span>    * @param [initialValue]
<span class='line'>676</span>    *
<span class='line'>677</span>    * @throws {TypeError} If &lt;var>callback&lt;/var> is not a function.
<span class='line'>678</span>    *
<span class='line'>679</span>    * @returns The result of the last &lt;var>callback&lt;/var> function invocation.
<span class='line'>680</span>    *
<span class='line'>681</span>    * @requires $.js.Array.reduceRight
<span class='line'>682</span>    * @see $.js.Array.reduceRight for more details and examples
<span class='line'>683</span>    * @see $.dom.NodeList.reduce
<span class='line'>684</span>    */</span><span class="WHIT">
<span class='line'>685</span> </span><span class="WHIT">  </span><span class="NAME">reduceRight</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.reduceRight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>686</span> 
<span class='line'>687</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>688</span>    * Create a new array containing the list of child elements of each item in 
<span class='line'>689</span>    * the current NodeList.
<span class='line'>690</span>    *
<span class='line'>691</span>    * @example
<span class='line'>692</span>    * // Given a DOM tree like:
<span class='line'>693</span>    * &lt;code>&lt;body&gt;
<span class='line'>694</span>    *   &lt;ul&gt;
<span class='line'>695</span>    *     &lt;li&gt;test 1.1&lt;/li&gt;
<span class='line'>696</span>    *     &lt;li&gt;test 1.2&lt;/li&gt;
<span class='line'>697</span>    *   &lt;/ul&gt;
<span class='line'>698</span>    *   &lt;ol&gt;
<span class='line'>699</span>    *     &lt;li&gt;test 2.1&lt;/li&gt;
<span class='line'>700</span>    *     &lt;li&gt;test 2.2&lt;/li&gt;
<span class='line'>701</span>    *   &lt;/ol&gt;
<span class='line'>702</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>703</span>    *
<span class='line'>704</span>    * // You can do:
<span class='line'>705</span>    * &lt;code>var &lt;var>elems&lt;/var> = document.body.childNodes.children();&lt;/code>
<span class='line'>706</span>    *
<span class='line'>707</span>    * // Now &lt;var>elems&lt;/var> is an array having four elements: the &lt;li&gt;
<span class='line'>708</span>    * // nodes from the two body child nodes, the &lt;ul&gt; and the &lt;ol&gt;.
<span class='line'>709</span>    *
<span class='line'>710</span>    * @returns {Array} The array containing the child elements of each item in 
<span class='line'>711</span>    * the current NodeList.
<span class='line'>712</span>    */</span><span class="WHIT">
<span class='line'>713</span> </span><span class="WHIT">  </span><span class="NAME">children</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>714</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>715</span> 
<span class='line'>716</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">elem.children</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT">        </span><span class="NAME">$.js.Array.forEach.call</span><span class="PUNC">(</span><span class="NAME">elem.children</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>719</span> </span><span class="WHIT">          </span><span class="NAME">resArr.push</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>720</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>723</span> 
<span class='line'>724</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>726</span> 
<span class='line'>727</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>728</span>    * Add the &lt;var>token&lt;/var> to the class list of each element in the current 
<span class='line'>729</span>    * NodeList.
<span class='line'>730</span>    *
<span class='line'>731</span>    * &lt;p>This method takes a single token, no spaces allowed.
<span class='line'>732</span>    *
<span class='line'>733</span>    * @example
<span class='line'>734</span>    * &lt;code>document.body.childNodes.addClass('test');&lt;/code>
<span class='line'>735</span>    *
<span class='line'>736</span>    * @param {String} token The token to add to the list of class names, for each 
<span class='line'>737</span>    * element in the current NodeList.
<span class='line'>738</span>    *
<span class='line'>739</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If the &lt;var>token&lt;/var> 
<span class='line'>740</span>    * contains a space character.
<span class='line'>741</span>    *
<span class='line'>742</span>    * @see $.dom.NodeList.hasClass
<span class='line'>743</span>    * @see $.dom.NodeList.toggleClass
<span class='line'>744</span>    * @see $.dom.NodeList.removeClass
<span class='line'>745</span>    */</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT">  </span><span class="NAME">addClass</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>747</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>749</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>750</span> 
<span class='line'>751</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>752</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">elem.classList</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>753</span> </span><span class="WHIT">        </span><span class="NAME">elem.classList.add</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>754</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>755</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>756</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>757</span> 
<span class='line'>758</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>759</span>    * Remove the &lt;var>token&lt;/var> from the class list of each element in the 
<span class='line'>760</span>    * current NodeList.
<span class='line'>761</span>    *
<span class='line'>762</span>    * &lt;p>This method takes a single token, no spaces allowed.
<span class='line'>763</span>    *
<span class='line'>764</span>    * @example
<span class='line'>765</span>    * &lt;code>document.body.childNodes.removeClass('test');&lt;/code>
<span class='line'>766</span>    *
<span class='line'>767</span>    * @param {String} token The token you want removed from the list of class 
<span class='line'>768</span>    * names, for each element in the current NodeList.
<span class='line'>769</span>    *
<span class='line'>770</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If the &lt;var>token&lt;/var> 
<span class='line'>771</span>    * contains a space character.
<span class='line'>772</span>    *
<span class='line'>773</span>    * @see $.dom.NodeList.addClass
<span class='line'>774</span>    * @see $.dom.NodeList.hasClass
<span class='line'>775</span>    * @see $.dom.NodeList.toggleClass
<span class='line'>776</span>    */</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">  </span><span class="NAME">removeClass</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>781</span> 
<span class='line'>782</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">elem.className</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>784</span>         </span><span class="NAME">elem.classList</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>785</span> </span><span class="WHIT">        </span><span class="NAME">elem.classList.remove</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>786</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>787</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>788</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>789</span> 
<span class='line'>790</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>791</span>    * Toggle the presence of &lt;var>token&lt;/var> in the class list of each element 
<span class='line'>792</span>    * in the current NodeList.
<span class='line'>793</span>    *
<span class='line'>794</span>    * &lt;p>This method takes a single token, no spaces allowed.
<span class='line'>795</span>    *
<span class='line'>796</span>    * &lt;p>For each element, it is checked if the &lt;var>token&lt;/var> is found in the 
<span class='line'>797</span>    * list of class names. If yes, then the &lt;var>token&lt;/var> is removed. If not, 
<span class='line'>798</span>    * then the &lt;var>token&lt;/var> is added.
<span class='line'>799</span>    *
<span class='line'>800</span>    * @example
<span class='line'>801</span>    * &lt;code>document.body.childNodes.toggleClass('test');&lt;/code>
<span class='line'>802</span>    *
<span class='line'>803</span>    * @param {String} token The token you want to toggle in the list of class 
<span class='line'>804</span>    * names, for each element in the current NodeList.
<span class='line'>805</span>    *
<span class='line'>806</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If the &lt;var>token&lt;/var> 
<span class='line'>807</span>    * contains a space character.
<span class='line'>808</span>    *
<span class='line'>809</span>    * @see $.dom.NodeList.addClass
<span class='line'>810</span>    * @see $.dom.NodeList.hasClass
<span class='line'>811</span>    * @see $.dom.NodeList.removeClass
<span class='line'>812</span>    */</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">  </span><span class="NAME">toggleClass</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>817</span> 
<span class='line'>818</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">elem.classList</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">        </span><span class="NAME">elem.classList.toggle</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>824</span> 
<span class='line'>825</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>826</span>    * Check if all the elements in the current NodeList have the &lt;var>token&lt;/var> 
<span class='line'>827</span>    * in their list of class names.
<span class='line'>828</span>    *
<span class='line'>829</span>    * &lt;p>This method takes a single token, no spaces allowed.
<span class='line'>830</span>    *
<span class='line'>831</span>    * @example
<span class='line'>832</span>    * &lt;code>document.body.childNodes.hasClass('test');&lt;/code>
<span class='line'>833</span>    *
<span class='line'>834</span>    * @param {String} token The token you want to toggle in the list of class 
<span class='line'>835</span>    * names, for each element in the current NodeList.
<span class='line'>836</span>    *
<span class='line'>837</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If the &lt;var>token&lt;/var> 
<span class='line'>838</span>    * contains a space character.
<span class='line'>839</span>    *
<span class='line'>840</span>    * @returns {Boolean} This method returns true if all the elements have the 
<span class='line'>841</span>    * &lt;var>token&lt;/var> in their class list. Otherwise, false is returned.
<span class='line'>842</span>    *
<span class='line'>843</span>    * @see $.dom.NodeList.addClass
<span class='line'>844</span>    * @see $.dom.NodeList.toggleClass
<span class='line'>845</span>    * @see $.dom.NodeList.removeClass
<span class='line'>846</span>    */</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">  </span><span class="NAME">hasClass</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>849</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>850</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>851</span> 
<span class='line'>852</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">found_elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.every</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>855</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>857</span> 
<span class='line'>858</span> </span><span class="WHIT">      </span><span class="NAME">found_elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>859</span> 
<span class='line'>860</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.className</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">elem.classList</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">elem.classList.has</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>862</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>863</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>864</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>865</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>866</span> 
<span class='line'>867</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">found_elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>868</span> </span><span class="WHIT">      </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>869</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>870</span> 
<span class='line'>871</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>872</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>873</span> 
<span class='line'>874</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>875</span>    * Set the value of an attribute, for each element in the current NodeList.
<span class='line'>876</span>    *
<span class='line'>877</span>    * @example
<span class='line'>878</span>    * // Set the border attribute for all images in the document.
<span class='line'>879</span>    * &lt;code>var imgs = $('img');
<span class='line'>880</span>    * imgs.setAttribute('border', 0);&lt;/code>
<span class='line'>881</span>    *
<span class='line'>882</span>    * @param {String} attr The attribute name.
<span class='line'>883</span>    * @param {String} val The attribute value you want to set.
<span class='line'>884</span>    *
<span class='line'>885</span>    * @see $.dom.NodeList.setAttributeNS
<span class='line'>886</span>    * @see $.dom.NodeList.removeAttribute
<span class='line'>887</span>    * @see $.dom.NodeList.removeAttributeNS
<span class='line'>888</span>    * @see $.dom.NodeList.hasAttribute
<span class='line'>889</span>    * @see $.dom.NodeList.hasAttributeNS
<span class='line'>890</span>    */</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">  </span><span class="NAME">setAttribute</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>893</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>894</span> </span><span class="WHIT">        </span><span class="NAME">elem.setAttribute</span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>896</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>897</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>898</span> 
<span class='line'>899</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>900</span>    * Set the value of a namespaced attribute, for each element in the current 
<span class='line'>901</span>    * NodeList.
<span class='line'>902</span>    *
<span class='line'>903</span>    * @example
<span class='line'>904</span>    * // Set the border attribute for all images in the document.
<span class='line'>905</span>    * &lt;code>var imgs = $('img'),
<span class='line'>906</span>    *     ns = '&lt;a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml&lt;/a>';
<span class='line'>907</span>    * imgs.setAttributeNS(ns, 'border', 0);&lt;/code>
<span class='line'>908</span>    *
<span class='line'>909</span>    * @param {String} ns The attribute XML namespace.
<span class='line'>910</span>    * @param {String} attr The attribute name.
<span class='line'>911</span>    * @param {String} val The attribute value you want to set.
<span class='line'>912</span>    *
<span class='line'>913</span>    * @see $.dom.NodeList.setAttribute
<span class='line'>914</span>    * @see $.dom.NodeList.removeAttribute
<span class='line'>915</span>    * @see $.dom.NodeList.removeAttributeNS
<span class='line'>916</span>    * @see $.dom.NodeList.hasAttribute
<span class='line'>917</span>    * @see $.dom.NodeList.hasAttributeNS
<span class='line'>918</span>    */</span><span class="WHIT">
<span class='line'>919</span> </span><span class="WHIT">  </span><span class="NAME">setAttributeNS</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>920</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>921</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>922</span> </span><span class="WHIT">        </span><span class="NAME">elem.setAttributeNS</span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>923</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>924</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>925</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>926</span> 
<span class='line'>927</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>928</span>    * Remove an attribute from all the elements in the current NodeList.
<span class='line'>929</span>    *
<span class='line'>930</span>    * @example
<span class='line'>931</span>    * // Remove the border attribute from all the images in the document.
<span class='line'>932</span>    * &lt;code>var imgs = $('img');
<span class='line'>933</span>    * imgs.removeAttribute('border');&lt;/code>
<span class='line'>934</span>    *
<span class='line'>935</span>    * @param {String} attr The attribute name to be removed.
<span class='line'>936</span>    *
<span class='line'>937</span>    * @see $.dom.NodeList.setAttribute
<span class='line'>938</span>    * @see $.dom.NodeList.setAttributeNS
<span class='line'>939</span>    * @see $.dom.NodeList.removeAttributeNS
<span class='line'>940</span>    * @see $.dom.NodeList.hasAttribute
<span class='line'>941</span>    * @see $.dom.NodeList.hasAttributeNS
<span class='line'>942</span>    */</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT">  </span><span class="NAME">removeAttribute</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>944</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>945</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>946</span> </span><span class="WHIT">        </span><span class="NAME">elem.removeAttribute</span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>947</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>948</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>949</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>950</span> 
<span class='line'>951</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>952</span>    * Remove a namespaced attribute from all the elements in the current 
<span class='line'>953</span>    * NodeList.
<span class='line'>954</span>    *
<span class='line'>955</span>    * @example
<span class='line'>956</span>    * // Remove the border attribute from all the images in the document.
<span class='line'>957</span>    * &lt;code>var imgs = $('img'),
<span class='line'>958</span>    *     ns = '&lt;a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml&lt;/a>';
<span class='line'>959</span>    * imgs.removeAttributeNS(ns, 'border');&lt;/code>
<span class='line'>960</span>    *
<span class='line'>961</span>    * @param {String} ns The attribute XML namespace.
<span class='line'>962</span>    * @param {String} attr The attribute name to be removed.
<span class='line'>963</span>    *
<span class='line'>964</span>    * @see $.dom.NodeList.setAttribute
<span class='line'>965</span>    * @see $.dom.NodeList.setAttributeNS
<span class='line'>966</span>    * @see $.dom.NodeList.removeAttribute
<span class='line'>967</span>    * @see $.dom.NodeList.hasAttribute
<span class='line'>968</span>    * @see $.dom.NodeList.hasAttributeNS
<span class='line'>969</span>    */</span><span class="WHIT">
<span class='line'>970</span> </span><span class="WHIT">  </span><span class="NAME">removeAttributeNS</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>971</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>972</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>973</span> </span><span class="WHIT">        </span><span class="NAME">elem.removeAttributeNS</span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>974</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>975</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>976</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>977</span> 
<span class='line'>978</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>979</span>    * Check if an attribute is defined for all the elements in the current 
<span class='line'>980</span>    * NodeList.
<span class='line'>981</span>    *
<span class='line'>982</span>    * @example
<span class='line'>983</span>    * // Check if the border attribute is set for all the image elements.
<span class='line'>984</span>    * &lt;code>var imgs = $('img');
<span class='line'>985</span>    * imgs.hasAttribute('border');&lt;/code>
<span class='line'>986</span>    *
<span class='line'>987</span>    * @param {String} attr The attribute name to be checked.
<span class='line'>988</span>    *
<span class='line'>989</span>    * @see $.dom.NodeList.setAttribute
<span class='line'>990</span>    * @see $.dom.NodeList.setAttributeNS
<span class='line'>991</span>    * @see $.dom.NodeList.removeAttribute
<span class='line'>992</span>    * @see $.dom.NodeList.removeAttributeNS
<span class='line'>993</span>    * @see $.dom.NodeList.hasAttributeNS
<span class='line'>994</span>    */</span><span class="WHIT">
<span class='line'>995</span> </span><span class="WHIT">  </span><span class="NAME">hasAttribute</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>996</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">found_elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>997</span> 
<span class='line'>998</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.every</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT">        </span><span class="NAME">found_elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">elem.hasAttribute</span><span class="PUNC">(</span><span class="NAME">attr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1006</span> 
<span class='line'>1007</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">found_elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1008</span> </span><span class="WHIT">      </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1010</span> 
<span class='line'>1011</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1012</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1013</span> 
<span class='line'>1014</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1015</span>    * Check if a namespaced attribute is defined for all the elements in the 
<span class='line'>1016</span>    * current NodeList.
<span class='line'>1017</span>    *
<span class='line'>1018</span>    * @example
<span class='line'>1019</span>    * // Check if the border attribute is set for all the image elements.
<span class='line'>1020</span>    * &lt;code>var imgs = $('img'),
<span class='line'>1021</span>    *     ns = '&lt;a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml&lt;/a>';
<span class='line'>1022</span>    * imgs.hasAttributeNS(ns, 'border');&lt;/code>
<span class='line'>1023</span>    *
<span class='line'>1024</span>    * @param {String} ns The attribute XML namespace.
<span class='line'>1025</span>    * @param {String} attr The attribute name to be checked.
<span class='line'>1026</span>    *
<span class='line'>1027</span>    * @see $.dom.NodeList.setAttribute
<span class='line'>1028</span>    * @see $.dom.NodeList.setAttributeNS
<span class='line'>1029</span>    * @see $.dom.NodeList.removeAttribute
<span class='line'>1030</span>    * @see $.dom.NodeList.removeAttributeNS
<span class='line'>1031</span>    * @see $.dom.NodeList.hasAttribute
<span class='line'>1032</span>    */</span><span class="WHIT">
<span class='line'>1033</span> </span><span class="WHIT">  </span><span class="NAME">hasAttributeNS</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1034</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">found_elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1035</span> 
<span class='line'>1036</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.every</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1037</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1038</span> </span><span class="WHIT">        </span><span class="NAME">found_elem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1039</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">elem.hasAttributeNS</span><span class="PUNC">(</span><span class="NAME">ns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1040</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1041</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1042</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1043</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1044</span> 
<span class='line'>1045</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">found_elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1046</span> </span><span class="WHIT">      </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1048</span> 
<span class='line'>1049</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1051</span> 
<span class='line'>1052</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1053</span>    * Insert a new node as the first child into each element from the current 
<span class='line'>1054</span>    * NodeList.
<span class='line'>1055</span>    *
<span class='line'>1056</span>    * &lt;p>Given a node, this method clones it for every element in the current 
<span class='line'>1057</span>    * NodeList. The clone is then inserted as the first child into each element.
<span class='line'>1058</span>    *
<span class='line'>1059</span>    * @example
<span class='line'>1060</span>    * // Given a DOM tree like:
<span class='line'>1061</span>    * &lt;code>&lt;body&gt;
<span class='line'>1062</span>    *   &lt;ul&gt;
<span class='line'>1063</span>    *     &lt;li&gt;test 1.1&lt;/li&gt;
<span class='line'>1064</span>    *     &lt;li&gt;test 1.2&lt;/li&gt;
<span class='line'>1065</span>    *   &lt;/ul&gt;
<span class='line'>1066</span>    *   &lt;ol&gt;
<span class='line'>1067</span>    *     &lt;li&gt;test 2.1&lt;/li&gt;
<span class='line'>1068</span>    *     &lt;li&gt;test 2.2&lt;/li&gt;
<span class='line'>1069</span>    *   &lt;/ol&gt;
<span class='line'>1070</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1071</span>    *
<span class='line'>1072</span>    * // You can do:
<span class='line'>1073</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('li');
<span class='line'>1074</span>    * &lt;var>elem&lt;/var>.className = 'test';&lt;/code>
<span class='line'>1075</span>    *
<span class='line'>1076</span>    * // Prepend the element to the document.body child nodes.
<span class='line'>1077</span>    * &lt;code>document.body.childNodes.prependChild(&lt;var>elem&lt;/var>);&lt;/code>
<span class='line'>1078</span>    *
<span class='line'>1079</span>    * // The body would then serialize to something like:
<span class='line'>1080</span>    * &lt;code>&lt;body&gt;
<span class='line'>1081</span>    *   &lt;ul&gt;
<span class='line'>1082</span>    *     &lt;li class="test"&gt;&lt;/li&gt;
<span class='line'>1083</span>    *     &lt;li&gt;test 1.1&lt;/li&gt;
<span class='line'>1084</span>    *     &lt;li&gt;test 1.2&lt;/li&gt;
<span class='line'>1085</span>    *   &lt;/ul&gt;
<span class='line'>1086</span>    *   &lt;ol&gt;
<span class='line'>1087</span>    *     &lt;li class="test"&gt;&lt;/li&gt;
<span class='line'>1088</span>    *     &lt;li&gt;test 2.1&lt;/li&gt;
<span class='line'>1089</span>    *     &lt;li&gt;test 2.2&lt;/li&gt;
<span class='line'>1090</span>    *   &lt;/ol&gt;
<span class='line'>1091</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1092</span>    *
<span class='line'>1093</span>    * @param {Node} child The node to prepend as a child.
<span class='line'>1094</span>    *
<span class='line'>1095</span>    * @returns {Array} An array containing the inserted child nodes.
<span class='line'>1096</span>    *
<span class='line'>1097</span>    * @see $.dom.NodeList.appendChild
<span class='line'>1098</span>    * @see $.dom.Node.prependChild
<span class='line'>1099</span>    */</span><span class="WHIT">
<span class='line'>1100</span> </span><span class="WHIT">  </span><span class="NAME">prependChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1101</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1102</span> 
<span class='line'>1103</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1104</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1105</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">child.cloneNode</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT">        </span><span class="NAME">resArr.push</span><span class="PUNC">(</span><span class="NAME">elem.insertBefore</span><span class="PUNC">(</span><span class="NAME">clone</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">elem.firstChild</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1109</span> 
<span class='line'>1110</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1112</span> 
<span class='line'>1113</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1114</span>    * Insert a new node as the last child into each element from the current 
<span class='line'>1115</span>    * NodeList.
<span class='line'>1116</span>    *
<span class='line'>1117</span>    * &lt;p>Given a node, this method clones it for every element in the current 
<span class='line'>1118</span>    * NodeList. The clone is then appended as the last child into each element.
<span class='line'>1119</span>    *
<span class='line'>1120</span>    * @example
<span class='line'>1121</span>    * // Given a DOM tree like:
<span class='line'>1122</span>    * &lt;code>&lt;body&gt;
<span class='line'>1123</span>    *   &lt;ul&gt;
<span class='line'>1124</span>    *     &lt;li&gt;test 1.1&lt;/li&gt;
<span class='line'>1125</span>    *     &lt;li&gt;test 1.2&lt;/li&gt;
<span class='line'>1126</span>    *   &lt;/ul&gt;
<span class='line'>1127</span>    *   &lt;ol&gt;
<span class='line'>1128</span>    *     &lt;li&gt;test 2.1&lt;/li&gt;
<span class='line'>1129</span>    *     &lt;li&gt;test 2.2&lt;/li&gt;
<span class='line'>1130</span>    *   &lt;/ol&gt;
<span class='line'>1131</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1132</span>    *
<span class='line'>1133</span>    * // You can do:
<span class='line'>1134</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.createElement('li');
<span class='line'>1135</span>    * &lt;var>elem&lt;/var>.className = 'test';&lt;/code>
<span class='line'>1136</span>    *
<span class='line'>1137</span>    * // Append the element to the document.body child nodes.
<span class='line'>1138</span>    * &lt;code>document.body.childNodes.appendChild(&lt;var>elem&lt;/var>);&lt;/code>
<span class='line'>1139</span>    *
<span class='line'>1140</span>    * // The body would then serialize to something like:
<span class='line'>1141</span>    * &lt;code>&lt;body&gt;
<span class='line'>1142</span>    *   &lt;ul&gt;
<span class='line'>1143</span>    *     &lt;li&gt;test 1.1&lt;/li&gt;
<span class='line'>1144</span>    *     &lt;li&gt;test 1.2&lt;/li&gt;
<span class='line'>1145</span>    *     &lt;li class="test"&gt;&lt;/li&gt;
<span class='line'>1146</span>    *   &lt;/ul&gt;
<span class='line'>1147</span>    *   &lt;ol&gt;
<span class='line'>1148</span>    *     &lt;li&gt;test 2.1&lt;/li&gt;
<span class='line'>1149</span>    *     &lt;li&gt;test 2.2&lt;/li&gt;
<span class='line'>1150</span>    *     &lt;li class="test"&gt;&lt;/li&gt;
<span class='line'>1151</span>    *   &lt;/ol&gt;
<span class='line'>1152</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1153</span>    *
<span class='line'>1154</span>    * @param {Node} child The node to append as a child.
<span class='line'>1155</span>    *
<span class='line'>1156</span>    * @returns {Array} An array containing the inserted child nodes.
<span class='line'>1157</span>    *
<span class='line'>1158</span>    * @see $.dom.NodeList.prependChild
<span class='line'>1159</span>    * @see $.dom.Node.prependChild
<span class='line'>1160</span>    */</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="WHIT">  </span><span class="NAME">appendChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1162</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1163</span> 
<span class='line'>1164</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1165</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1166</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">child.cloneNode</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1167</span> </span><span class="WHIT">        </span><span class="NAME">resArr.push</span><span class="PUNC">(</span><span class="NAME">elem.appendChild</span><span class="PUNC">(</span><span class="NAME">clone</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1168</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1169</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1170</span> 
<span class='line'>1171</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1172</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1173</span> 
<span class='line'>1174</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1175</span>    * Prepend all the nodes in the current NodeList to the &lt;var>target&lt;/var> 
<span class='line'>1176</span>    * node. All the nodes are inserted maintaining the same order as in the 
<span class='line'>1177</span>    * current NodeList.
<span class='line'>1178</span>    *
<span class='line'>1179</span>    * @example
<span class='line'>1180</span>    * // Given a DOM tree like:
<span class='line'>1181</span>    * &lt;code>&lt;body&gt;
<span class='line'>1182</span>    *   &lt;div&gt;
<span class='line'>1183</span>    *     &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1184</span>    *     &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1185</span>    *   &lt;/div&gt;
<span class='line'>1186</span>    *   &lt;p&gt;Test 1&lt;/p&gt;
<span class='line'>1187</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1188</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1189</span>    *
<span class='line'>1190</span>    * // You can do the following:
<span class='line'>1191</span>    * &lt;code>var &lt;var>div&lt;/var> = document.body.firstElementChild;&lt;/code>
<span class='line'>1192</span>    *
<span class='line'>1193</span>    * // Move the &lt;div&gt; child nodes into the body element.
<span class='line'>1194</span>    * &lt;code>&lt;var>div&lt;/var>.childNodes.prependTo(document.body);&lt;/code>
<span class='line'>1195</span>    *
<span class='line'>1196</span>    * // Now the body would serialize to something like:
<span class='line'>1197</span>    * &lt;code>&lt;body&gt;
<span class='line'>1198</span>    *   &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1199</span>    *   &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1200</span>    *   &lt;div&gt;&lt;/div&gt;
<span class='line'>1201</span>    *   &lt;p&gt;Test 1&lt;/p&gt;
<span class='line'>1202</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1203</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1204</span>    *
<span class='line'>1205</span>    * @param {Node} target The target node where to prepend all of the nodes from 
<span class='line'>1206</span>    * the current NodeList.
<span class='line'>1207</span>    *
<span class='line'>1208</span>    * @throws {TypeError} If &lt;var>target&lt;/var> is not an instance of Node.
<span class='line'>1209</span>    *
<span class='line'>1210</span>    * @returns {NodeList} The child nodes of the &lt;var>target&lt;/var> node.
<span class='line'>1211</span>    * (&lt;code>&lt;var>target&lt;/var>.childNodes&lt;/code>)
<span class='line'>1212</span>    *
<span class='line'>1213</span>    * @see $.dom.NodeList.appendTo
<span class='line'>1214</span>    * @see $.dom.Node.prependTo
<span class='line'>1215</span>    * @see $.dom.Node.appendTo
<span class='line'>1216</span>    */</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT">  </span><span class="NAME">prependTo</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1218</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1219</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1220</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1221</span> 
<span class='line'>1222</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">target</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1223</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1224</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1225</span> 
<span class='line'>1226</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">target.firstChild</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1227</span> 
<span class='line'>1228</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1229</span> </span><span class="WHIT">      </span><span class="NAME">target.insertBefore</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">first</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1230</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1231</span> 
<span class='line'>1232</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">target.childNodes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1233</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1234</span> 
<span class='line'>1235</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1236</span>    * Append all the nodes in the current NodeList to the &lt;var>target&lt;/var> node.  
<span class='line'>1237</span>    * All the nodes are inserted maintaining the same order as in the current 
<span class='line'>1238</span>    * NodeList.
<span class='line'>1239</span>    *
<span class='line'>1240</span>    * @example
<span class='line'>1241</span>    * // Given a DOM tree like:
<span class='line'>1242</span>    * &lt;code>&lt;body&gt;
<span class='line'>1243</span>    *   &lt;div&gt;
<span class='line'>1244</span>    *     &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1245</span>    *     &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1246</span>    *   &lt;/div&gt;
<span class='line'>1247</span>    *   &lt;p&gt;Test 1&lt;/p&gt;
<span class='line'>1248</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1249</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1250</span>    *
<span class='line'>1251</span>    * // You can do the following:
<span class='line'>1252</span>    * &lt;code>var &lt;var>div&lt;/var> = document.body.firstElementChild;&lt;/code>
<span class='line'>1253</span>    *
<span class='line'>1254</span>    * // Move the &lt;div&gt; child nodes into the body element.
<span class='line'>1255</span>    * &lt;code>&lt;var>div&lt;/var>.childNodes.appendTo(document.body);&lt;/code>
<span class='line'>1256</span>    *
<span class='line'>1257</span>    * // Now the body would serialize to something like:
<span class='line'>1258</span>    * &lt;code>&lt;body&gt;
<span class='line'>1259</span>    *   &lt;div&gt;&lt;/div&gt;
<span class='line'>1260</span>    *   &lt;p&gt;Test 1&lt;/p&gt;
<span class='line'>1261</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1262</span>    *   &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1263</span>    *   &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1264</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1265</span>    *
<span class='line'>1266</span>    * @param {Node} target The target node where to append all of the nodes from 
<span class='line'>1267</span>    * the current NodeList.
<span class='line'>1268</span>    *
<span class='line'>1269</span>    * @throws {TypeError} If &lt;var>target&lt;/var> is not an instance of Node.
<span class='line'>1270</span>    *
<span class='line'>1271</span>    * @returns {NodeList} The child nodes of the &lt;var>target&lt;/var> node.
<span class='line'>1272</span>    * (&lt;code>&lt;var>target&lt;/var>.childNodes&lt;/code>)
<span class='line'>1273</span>    *
<span class='line'>1274</span>    * @see $.dom.NodeList.prependTo
<span class='line'>1275</span>    * @see $.dom.Node.prependTo
<span class='line'>1276</span>    * @see $.dom.Node.appendTo
<span class='line'>1277</span>    */</span><span class="WHIT">
<span class='line'>1278</span> </span><span class="WHIT">  </span><span class="NAME">appendTo</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">target</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1279</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1280</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1281</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1282</span> 
<span class='line'>1283</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">target</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1284</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM node.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1285</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1286</span> 
<span class='line'>1287</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1288</span> </span><span class="WHIT">      </span><span class="NAME">target.appendChild</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1289</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1290</span> 
<span class='line'>1291</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">target.childNodes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1292</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1293</span> 
<span class='line'>1294</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1295</span>    * Insert all the nodes in the current NodeList before a reference element.
<span class='line'>1296</span>    *
<span class='line'>1297</span>    * &lt;p>The reference element must have a parent element. All the nodes from the 
<span class='line'>1298</span>    * current NodeList will be inserted into the parent element. The inserted 
<span class='line'>1299</span>    * nodes will be positioned before the reference element.
<span class='line'>1300</span>    *
<span class='line'>1301</span>    * @example
<span class='line'>1302</span>    * // Given a DOM tree like:
<span class='line'>1303</span>    * &lt;code>&lt;body&gt;
<span class='line'>1304</span>    *   &lt;div&gt;
<span class='line'>1305</span>    *     &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1306</span>    *     &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1307</span>    *   &lt;/div&gt;
<span class='line'>1308</span>    *   &lt;p id="test1"&gt;Test 1&lt;/p&gt;
<span class='line'>1309</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1310</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1311</span>    *
<span class='line'>1312</span>    * // You can do the following:
<span class='line'>1313</span>    * &lt;code>var &lt;var>div&lt;/var> = document.body.firstElementChild,
<span class='line'>1314</span>    *     &lt;var>test1&lt;/var> = $('#test1');&lt;/code>
<span class='line'>1315</span>    *
<span class='line'>1316</span>    * // Move the &lt;div&gt; child nodes before &lt;var>test1&lt;/var>.
<span class='line'>1317</span>    * &lt;code>&lt;var>div&lt;/var>.childNodes.insertBefore(&lt;var>test1&lt;/var>);&lt;/code>
<span class='line'>1318</span>    *
<span class='line'>1319</span>    * // Now the body would serialize to something like:
<span class='line'>1320</span>    * &lt;code>&lt;body&gt;
<span class='line'>1321</span>    *   &lt;div&gt;&lt;/div&gt;
<span class='line'>1322</span>    *   &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1323</span>    *   &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1324</span>    *   &lt;p id="test1"&gt;Test 1&lt;/p&gt;
<span class='line'>1325</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1326</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1327</span>    *
<span class='line'>1328</span>    * @param {Element} ref The reference element.
<span class='line'>1329</span>    *
<span class='line'>1330</span>    * @throws {TypeError} If &lt;var>ref&lt;/var> is not an element node.
<span class='line'>1331</span>    * @throws {ReferenceError} If &lt;var>ref.parentNode&lt;/var> is not an element 
<span class='line'>1332</span>    * node.
<span class='line'>1333</span>    *
<span class='line'>1334</span>    * @returns {NodeList} The NodeList containing the child nodes of the 
<span class='line'>1335</span>    * reference parent element.
<span class='line'>1336</span>    * (&lt;code>&lt;var>ref&lt;/var>.parentNode.childNodes&lt;/code>)
<span class='line'>1337</span>    *
<span class='line'>1338</span>    * @see $.dom.NodeList.insertAfter
<span class='line'>1339</span>    * @see $.dom.Node.insertAfter
<span class='line'>1340</span>    */</span><span class="WHIT">
<span class='line'>1341</span> </span><span class="WHIT">  </span><span class="NAME">insertBefore</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ref</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1342</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ref.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1343</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM element.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1344</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1345</span> 
<span class='line'>1346</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">parentNode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ref.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1347</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">parentNode.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1348</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ReferenceError</span><span class="PUNC">(</span><span class="STRN">'The first argument must have a parent element.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1349</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1350</span> 
<span class='line'>1351</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1352</span> </span><span class="WHIT">      </span><span class="NAME">parentNode.insertBefore</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ref</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1353</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1354</span> 
<span class='line'>1355</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">parentNode.childNodes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1356</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1357</span> 
<span class='line'>1358</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1359</span>    * Insert all the nodes in the current NodeList after a reference element.
<span class='line'>1360</span>    *
<span class='line'>1361</span>    * &lt;p>The reference element must have a parent element. All the nodes from the 
<span class='line'>1362</span>    * current NodeList will be inserted into the parent element. The inserted 
<span class='line'>1363</span>    * nodes will be positioned after the reference element.
<span class='line'>1364</span>    *
<span class='line'>1365</span>    * @example
<span class='line'>1366</span>    * // Given a DOM tree like:
<span class='line'>1367</span>    * &lt;code>&lt;body&gt;
<span class='line'>1368</span>    *   &lt;div&gt;
<span class='line'>1369</span>    *     &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1370</span>    *     &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1371</span>    *   &lt;/div&gt;
<span class='line'>1372</span>    *   &lt;p id="test1"&gt;Test 1&lt;/p&gt;
<span class='line'>1373</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1374</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1375</span>    *
<span class='line'>1376</span>    * // You can do the following:
<span class='line'>1377</span>    * &lt;code>var &lt;var>div&lt;/var> = document.body.firstElementChild,
<span class='line'>1378</span>    *     &lt;var>test1&lt;/var> = $('#test1');&lt;/code>
<span class='line'>1379</span>    *
<span class='line'>1380</span>    * // Move the &lt;div&gt; child nodes after &lt;var>test1&lt;/var>.
<span class='line'>1381</span>    * &lt;code>&lt;var>div&lt;/var>.childNodes.insertAfter(&lt;var>test1&lt;/var>);&lt;/code>
<span class='line'>1382</span>    *
<span class='line'>1383</span>    * // Now the body would serialize to something like:
<span class='line'>1384</span>    * &lt;code>&lt;body&gt;
<span class='line'>1385</span>    *   &lt;div&gt;&lt;/div&gt;
<span class='line'>1386</span>    *   &lt;p id="test1"&gt;Test 1&lt;/p&gt;
<span class='line'>1387</span>    *   &lt;p&gt;test a&lt;/p&gt;
<span class='line'>1388</span>    *   &lt;p&gt;test b&lt;/p&gt;
<span class='line'>1389</span>    *   &lt;p&gt;Test 2&lt;/p&gt;
<span class='line'>1390</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1391</span>    *
<span class='line'>1392</span>    * @param {Element} ref The reference element.
<span class='line'>1393</span>    *
<span class='line'>1394</span>    * @throws {TypeError} If &lt;var>ref&lt;/var> is not an element node.
<span class='line'>1395</span>    * @throws {ReferenceError} If &lt;var>ref.parentNode&lt;/var> is not an element 
<span class='line'>1396</span>    * node.
<span class='line'>1397</span>    *
<span class='line'>1398</span>    * @returns {NodeList} The NodeList containing the child nodes of the 
<span class='line'>1399</span>    * reference parent element.
<span class='line'>1400</span>    * (&lt;code>&lt;var>ref&lt;/var>.parentNode.childNodes&lt;/code>)
<span class='line'>1401</span>    *
<span class='line'>1402</span>    * @see $.dom.NodeList.insertBefore
<span class='line'>1403</span>    * @see $.dom.Node.insertAfter
<span class='line'>1404</span>    */</span><span class="WHIT">
<span class='line'>1405</span> </span><span class="WHIT">  </span><span class="NAME">insertAfter</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ref</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1406</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1407</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1408</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1409</span> 
<span class='line'>1410</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ref.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1411</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be a DOM element.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1412</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1413</span> 
<span class='line'>1414</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">parentNode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ref.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1415</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">parentNode.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1416</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ReferenceError</span><span class="PUNC">(</span><span class="STRN">'The first argument must have a parent element.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1417</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1418</span> 
<span class='line'>1419</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">before</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ref.nextSibling</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1420</span> </span><span class="WHIT">    </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1421</span> </span><span class="WHIT">      </span><span class="NAME">parentNode.insertBefore</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">before</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1422</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1423</span> 
<span class='line'>1424</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">parentNode.childNodes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1425</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1426</span> 
<span class='line'>1427</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1428</span>    * Remove the first child from each element in the current NodeList.
<span class='line'>1429</span>    *
<span class='line'>1430</span>    * @returns {Array} The array returned contains references to the removed 
<span class='line'>1431</span>    * nodes.
<span class='line'>1432</span>    *
<span class='line'>1433</span>    * @see $.dom.NodeList.removeLastChild
<span class='line'>1434</span>    * @see $.dom.Node.removeFirstChild
<span class='line'>1435</span>    * @see $.dom.Node.removeLastChild
<span class='line'>1436</span>    */</span><span class="WHIT">
<span class='line'>1437</span> </span><span class="WHIT">  </span><span class="NAME">removeFirstChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1438</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1439</span> 
<span class='line'>1440</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1441</span> </span><span class="WHIT">      </span><span class="NAME">resArr.push</span><span class="PUNC">(</span><span class="NAME">node.removeChild</span><span class="PUNC">(</span><span class="NAME">node.firstChild</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1442</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1443</span> 
<span class='line'>1444</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1445</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1446</span> 
<span class='line'>1447</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1448</span>    * Remove the last child from each element in the current NodeList.
<span class='line'>1449</span>    *
<span class='line'>1450</span>    * @returns {Array} The array returned contains references to the removed 
<span class='line'>1451</span>    * nodes.
<span class='line'>1452</span>    *
<span class='line'>1453</span>    * @see $.dom.NodeList.removeFirstChild
<span class='line'>1454</span>    * @see $.dom.Node.removeFirstChild
<span class='line'>1455</span>    * @see $.dom.Node.removeLastChild
<span class='line'>1456</span>    */</span><span class="WHIT">
<span class='line'>1457</span> </span><span class="WHIT">  </span><span class="NAME">removeLastChild</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1458</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1459</span> 
<span class='line'>1460</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1461</span> </span><span class="WHIT">      </span><span class="NAME">resArr.push</span><span class="PUNC">(</span><span class="NAME">node.removeChild</span><span class="PUNC">(</span><span class="NAME">node.lastChild</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1462</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1463</span> 
<span class='line'>1464</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1465</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1466</span> 
<span class='line'>1467</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1468</span>    * Remove all the child nodes from each element in the current NodeList.
<span class='line'>1469</span>    *
<span class='line'>1470</span>    * @returns {Array} The array returned contains references to the removed 
<span class='line'>1471</span>    * nodes.
<span class='line'>1472</span>    */</span><span class="WHIT">
<span class='line'>1473</span> </span><span class="WHIT">  </span><span class="NAME">empty</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1474</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1475</span> 
<span class='line'>1476</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1477</span> </span><span class="WHIT">      </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node.hasChildNodes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1478</span> </span><span class="WHIT">        </span><span class="NAME">resArr.push</span><span class="PUNC">(</span><span class="NAME">node.removeChild</span><span class="PUNC">(</span><span class="NAME">node.firstChild</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1479</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1480</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1481</span> 
<span class='line'>1482</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">resArr</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1483</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1484</span> 
<span class='line'>1485</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1486</span>    * Wrap each node from the current NodeList inside the given 
<span class='line'>1487</span>    * &lt;var>wrapper&lt;/var>.
<span class='line'>1488</span>    *
<span class='line'>1489</span>    * &lt;p>This method clones the &lt;var>wrapper&lt;/var> for each node in the current 
<span class='line'>1490</span>    * NodeList. Then each node is inserted into its own wrapper clone. The effect 
<span class='line'>1491</span>    * of this action is that the current NodeList will only hold the cloned 
<span class='line'>1492</span>    * wrapper nodes themselves, after this method executes. The length of the 
<span class='line'>1493</span>    * NodeList does not change.
<span class='line'>1494</span>    *
<span class='line'>1495</span>    * @example
<span class='line'>1496</span>    * // Given a DOM tree like the following:
<span class='line'>1497</span>    * &lt;code>&lt;body&gt;
<span class='line'>1498</span>    *   &lt;ul&gt;
<span class='line'>1499</span>    *     &lt;p&gt;test 1&lt;/p&gt;
<span class='line'>1500</span>    *     &lt;p&gt;test 2&lt;/p&gt;
<span class='line'>1501</span>    *   &lt;/ul&gt;
<span class='line'>1502</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1503</span>    *
<span class='line'>1504</span>    * // You can do:
<span class='line'>1505</span>    * &lt;code>$('body &gt; ul')[0].childNodes.wrapEach('&lt;li&gt;');&lt;/code>
<span class='line'>1506</span>    *
<span class='line'>1507</span>    * // The body would then serialize to:
<span class='line'>1508</span>    * &lt;code>&lt;body&gt;
<span class='line'>1509</span>    *   &lt;ul&gt;
<span class='line'>1510</span>    *     &lt;li&gt;&lt;p&gt;test 1&lt;/p&gt;&lt;/li&gt;
<span class='line'>1511</span>    *     &lt;li&gt;&lt;p&gt;test 2&lt;/p&gt;&lt;/li&gt;
<span class='line'>1512</span>    *   &lt;/ul&gt;
<span class='line'>1513</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1514</span>    *
<span class='line'>1515</span>    * @param {Element|String} wrapper The element or the string to use for 
<span class='line'>1516</span>    * wrapping each node.
<span class='line'>1517</span>    *
<span class='line'>1518</span>    * @see $.dom.Element.wrap for more details and examples
<span class='line'>1519</span>    */</span><span class="WHIT">
<span class='line'>1520</span> </span><span class="WHIT">  </span><span class="NAME">wrapEach</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">node.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.TEXT_NODE</span><span class="WHIT"> 
<span class='line'>1523</span>         </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">node.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.COMMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1524</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1525</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1526</span> 
<span class='line'>1527</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1528</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1529</span> </span><span class="WHIT">        </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapper.cloneNode</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1530</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1531</span> 
<span class='line'>1532</span> </span><span class="WHIT">      </span><span class="NAME">$.dom.Element.wrap.call</span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1533</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1534</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1535</span> 
<span class='line'>1536</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1537</span>    * Wrap all the nodes from the current NodeList inside a single 
<span class='line'>1538</span>    * &lt;var>wrapper&lt;/var>.
<span class='line'>1539</span>    *
<span class='line'>1540</span>    * &lt;p>This method moves all the nodes from the current NodeList into the given 
<span class='line'>1541</span>    * &lt;var>wrapper&lt;/var>. The effect of this action is that the current NodeList 
<span class='line'>1542</span>    * will only hold one child node (the &lt;var>wrapper&lt;/var>) after this method 
<span class='line'>1543</span>    * executes.
<span class='line'>1544</span>    *
<span class='line'>1545</span>    * @example
<span class='line'>1546</span>    * // Given a DOM tree like the following:
<span class='line'>1547</span>    * &lt;code>&lt;body&gt;
<span class='line'>1548</span>    *   &lt;p&gt;test 1&lt;/p&gt;
<span class='line'>1549</span>    *   &lt;p&gt;test 2&lt;/p&gt;
<span class='line'>1550</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1551</span>    *
<span class='line'>1552</span>    * // You can do:
<span class='line'>1553</span>    * &lt;code>document.body.childNodes.wrapAll('&lt;div&gt;');&lt;/code>
<span class='line'>1554</span>    *
<span class='line'>1555</span>    * // The body would then serialize to:
<span class='line'>1556</span>    * &lt;code>&lt;body&gt;
<span class='line'>1557</span>    *   &lt;div&gt;
<span class='line'>1558</span>    *     &lt;p&gt;test 1&lt;/p&gt;
<span class='line'>1559</span>    *     &lt;p&gt;test 2&lt;/p&gt;
<span class='line'>1560</span>    *   &lt;/div&gt;
<span class='line'>1561</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1562</span>    *
<span class='line'>1563</span>    * @param {Element|String} wrapper The element or the string to use for 
<span class='line'>1564</span>    * wrapping all the nodes.
<span class='line'>1565</span>    *
<span class='line'>1566</span>    * @returns {NodeList} The list of wrapped child nodes.
<span class='line'>1567</span>    * (&lt;code>&lt;var>wrapper&lt;/var>.childNodes&lt;/code>)
<span class='line'>1568</span>    *
<span class='line'>1569</span>    * @see $.dom.Element.wrap for more details and examples
<span class='line'>1570</span>    */</span><span class="WHIT">
<span class='line'>1571</span> </span><span class="WHIT">  </span><span class="NAME">wrapAll</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1572</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1573</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1574</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1575</span> 
<span class='line'>1576</span> </span><span class="WHIT">    </span><span class="COMM">// Make a static list of nodes.</span><span class="WHIT">
<span class='line'>1577</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">arr</span><span class="WHIT">   </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.toArray</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1578</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arr.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1579</span> 
<span class='line'>1580</span> </span><span class="WHIT">    </span><span class="NAME">$.dom.Element.wrap.call</span><span class="PUNC">(</span><span class="NAME">first</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1581</span> 
<span class='line'>1582</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pNode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">first.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1583</span> 
<span class='line'>1584</span> </span><span class="WHIT">    </span><span class="COMM">// Add the rest of the child nodes into the wrapper.</span><span class="WHIT">
<span class='line'>1585</span> </span><span class="WHIT">    </span><span class="NAME">$.js.Array.forEach.call</span><span class="PUNC">(</span><span class="NAME">arr</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1586</span> </span><span class="WHIT">      </span><span class="NAME">pNode.appendChild</span><span class="PUNC">(</span><span class="NAME">child</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1587</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1588</span> 
<span class='line'>1589</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pNode.childNodes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1590</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1591</span> 
<span class='line'>1592</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1593</span>    * Wrap the content of the nodes from the current NodeList inside the given 
<span class='line'>1594</span>    * &lt;var>wrapper&lt;/var>.
<span class='line'>1595</span>    *
<span class='line'>1596</span>    * &lt;p>This method wraps the content of the nodes from the current NodeList 
<span class='line'>1597</span>    * into clones of the given &lt;var>wrapper&lt;/var>.
<span class='line'>1598</span>    *
<span class='line'>1599</span>    * @example
<span class='line'>1600</span>    * // Given a DOM tree like the following:
<span class='line'>1601</span>    * &lt;code>&lt;body&gt;
<span class='line'>1602</span>    *   &lt;p&gt;test 1&lt;/p&gt;
<span class='line'>1603</span>    *   &lt;p&gt;test 2&lt;/p&gt;
<span class='line'>1604</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1605</span>    *
<span class='line'>1606</span>    * // You can do:
<span class='line'>1607</span>    * &lt;code>document.body.childNodes.wrapInner('&lt;strong&gt;');&lt;/code>
<span class='line'>1608</span>    *
<span class='line'>1609</span>    * // The body would then serialize to:
<span class='line'>1610</span>    * &lt;code>&lt;body&gt;
<span class='line'>1611</span>    *   &lt;p&gt;&lt;strong&gt;test 1&lt;/strong&gt;&lt;/p&gt;
<span class='line'>1612</span>    *   &lt;p&gt;&lt;strong&gt;test 2&lt;/strong&gt;&lt;/p&gt;
<span class='line'>1613</span>    * &lt;/body&gt;&lt;/code>
<span class='line'>1614</span>    *
<span class='line'>1615</span>    * @param {Element|String} wrapper The element or the string to use for 
<span class='line'>1616</span>    * wrapping the content of all the nodes in the current NodeList.
<span class='line'>1617</span>    *
<span class='line'>1618</span>    * @see $.dom.Element.wrap for more details and examples
<span class='line'>1619</span>    */</span><span class="WHIT">
<span class='line'>1620</span> </span><span class="WHIT">  </span><span class="NAME">wrapInner</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1621</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1622</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">node.hasChildNodes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1623</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1624</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1625</span> 
<span class='line'>1626</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapper</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1627</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">wrapper</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1628</span> </span><span class="WHIT">        </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">wrapper.cloneNode</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1629</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1630</span> </span><span class="WHIT">      </span><span class="NAME">$.dom.NodeList.wrapAll.call</span><span class="PUNC">(</span><span class="NAME">node.childNodes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1631</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1632</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1633</span> 
<span class='line'>1634</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>1635</span>    * Get/set the style for all the elements in the current NodeList.
<span class='line'>1636</span>    *
<span class='line'>1637</span>    * &lt;p>If the &lt;var>property&lt;/var> argument is a string, but the 
<span class='line'>1638</span>    * &lt;var>value&lt;/var> is undefined, then this method finds the first element 
<span class='line'>1639</span>    * child in the current NodeList. The computed style of &lt;var>property&lt;/var> is 
<span class='line'>1640</span>    * returned.
<span class='line'>1641</span>    *
<span class='line'>1642</span>    * &lt;p>If the &lt;var>property&lt;/var> and the &lt;var>value&lt;/var> arguments are both 
<span class='line'>1643</span>    * strings, then this method changes the style &lt;var>property&lt;/var> to 
<span class='line'>1644</span>    * &lt;var>value&lt;/var>. This is done for all the elements in the current 
<span class='line'>1645</span>    * NodeList.
<span class='line'>1646</span>    *
<span class='line'>1647</span>    * &lt;p>Similarly, if the &lt;var>property&lt;/var> argument is an object, then all 
<span class='line'>1648</span>    * the values and properties in the object are used for changing the styles 
<span class='line'>1649</span>    * for all the elements in the current NodeList.
<span class='line'>1650</span>    *
<span class='line'>1651</span>    * @param {String|Object} property The style property name to get/set (if the 
<span class='line'>1652</span>    * argument is a string), or the list of properties to set (if the argument is 
<span class='line'>1653</span>    * an object).
<span class='line'>1654</span>    *
<span class='line'>1655</span>    * @param {String} [value] The value you want to set for the given 
<span class='line'>1656</span>    * &lt;var>property&lt;/var>.
<span class='line'>1657</span>    *
<span class='line'>1658</span>    * @throws {TypeError} If the &lt;var>property&lt;/var> argument is not a string, 
<span class='line'>1659</span>    * nor an object.
<span class='line'>1660</span>    *
<span class='line'>1661</span>    * @returns {String|undefined} If the &lt;var>property&lt;/var> argument is a string 
<span class='line'>1662</span>    * and  if the &lt;var>value&lt;/var> argument is undefined, then this method 
<span class='line'>1663</span>    * returns the computed style of the given &lt;var>property&lt;/var>. Otherwise, 
<span class='line'>1664</span>    * this method does not return anything.
<span class='line'>1665</span>    *
<span class='line'>1666</span>    * @see $.dom.getStyle
<span class='line'>1667</span>    */</span><span class="WHIT">
<span class='line'>1668</span> </span><span class="WHIT">  </span><span class="NAME">style</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">property</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1669</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1670</span> 
<span class='line'>1671</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">property</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1672</span> 
<span class='line'>1673</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1674</span> </span><span class="WHIT">      </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1675</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">nodeType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT">          </span><span class="NAME">first</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1677</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT">        </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1679</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1680</span> 
<span class='line'>1681</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$.dom.getStyle</span><span class="PUNC">(</span><span class="NAME">first</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">property</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1682</span> 
<span class='line'>1683</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">property</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1684</span> </span><span class="WHIT">      </span><span class="NAME">list</span><span class="PUNC">[</span><span class="NAME">property</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1685</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">property</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Object</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1686</span> </span><span class="WHIT">      </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">property</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1687</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'Invalid arguments.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1690</span> 
<span class='line'>1691</span> </span><span class="WHIT">    </span><span class="NAME">this.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1692</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.nodeType</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">Node.ELEMENT_NODE</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1693</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1694</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1695</span> 
<span class='line'>1696</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">property</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">list</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1697</span> </span><span class="WHIT">        </span><span class="NAME">elem.style</span><span class="PUNC">[</span><span class="NAME">property</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list</span><span class="PUNC">[</span><span class="NAME">property</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1698</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1699</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1700</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1701</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1702</span> 
<span class='line'>1703</span> </span><span class="COMM">// Extending the HTMLCollection object has no effect in Gecko (tested Firefox </span><span class="WHIT">
<span class='line'>1704</span> </span><span class="COMM">// 3.2 pre-alpha, build 20090303).</span><span class="WHIT">
<span class='line'>1705</span> </span><span class="COMM">// See: https://bugzilla.mozilla.org/show_bug.cgi?id=300519</span><span class="WHIT">
<span class='line'>1706</span> </span><span class="NAME">$.dom.HTMLCollection</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.NodeList</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1707</span> 
<span class='line'>1708</span> 
<span class='line'>1709</span> </span><span class="COMM">// Add the Array methods to the NamedNodeMap.</span><span class="WHIT">
<span class='line'>1710</span> </span><span class="COMM">// From the spec: Objects implementing the NamedNodeMap interface are used to </span><span class="WHIT">
<span class='line'>1711</span> </span><span class="COMM">// represent collections of nodes that can be accessed by name. Note that </span><span class="WHIT">
<span class='line'>1712</span> </span><span class="COMM">// NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained </span><span class="WHIT">
<span class='line'>1713</span> </span><span class="COMM">// in any particular order. Objects contained in an object implementing </span><span class="WHIT">
<span class='line'>1714</span> </span><span class="COMM">// NamedNodeMap may also be accessed by an ordinal index, but this is simply to </span><span class="WHIT">
<span class='line'>1715</span> </span><span class="COMM">// allow convenient enumeration of the contents of a NamedNodeMap, and does not </span><span class="WHIT">
<span class='line'>1716</span> </span><span class="COMM">// imply that the DOM specifies an order to these Nodes.</span><span class="WHIT">
<span class='line'>1717</span> </span><span class="NAME">$.dom.NamedNodeMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1718</span> </span><span class="WHIT">  </span><span class="STRN">'slice'</span><span class="WHIT">       </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.slice</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1719</span> </span><span class="WHIT">  </span><span class="STRN">'filter'</span><span class="WHIT">      </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.filter</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1720</span> </span><span class="WHIT">  </span><span class="STRN">'forEach'</span><span class="WHIT">     </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.forEach</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1721</span> </span><span class="WHIT">  </span><span class="STRN">'every'</span><span class="WHIT">       </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.every</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1722</span> </span><span class="WHIT">  </span><span class="STRN">'some'</span><span class="WHIT">        </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.some</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1723</span> </span><span class="WHIT">  </span><span class="STRN">'map'</span><span class="WHIT">         </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.map</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1724</span> </span><span class="WHIT">  </span><span class="STRN">'reduce'</span><span class="WHIT">      </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.reduce</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1725</span> </span><span class="WHIT">  </span><span class="STRN">'reduceRight'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.reduceRight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1726</span> </span><span class="WHIT">  </span><span class="STRN">'indexOf'</span><span class="WHIT">     </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.indexOf</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1727</span> </span><span class="WHIT">  </span><span class="STRN">'lastIndexOf'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.js.Array.lastIndexOf</span><span class="WHIT">
<span class='line'>1728</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1729</span> 
<span class='line'>1730</span> 
<span class='line'>1731</span> </span><span class="COMM">/*
<span class='line'>1732</span>  * NOTE: This is only tested and known to semi-work in MSIE 8.
<span class='line'>1733</span>  * 
<span class='line'>1734</span>  * Emulate minimal support for DOM Events. We also check for the presence of the 
<span class='line'>1735</span>  * methods, maybe MSIE will one day implement them.
<span class='line'>1736</span>  *
<span class='line'>1737</span>  * This works fine only if you add event listeners. You won't be able to detach 
<span class='line'>1738</span>  * events.
<span class='line'>1739</span>  */</span><span class="WHIT">
<span class='line'>1740</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.attachEvent</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.detachEvent</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>1741</span>     </span><span class="PUNC">!</span><span class="NAME">document.addEventListener</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">document.removeEventListener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1742</span> </span><span class="WHIT">  </span><span class="NAME">$.dom.EventTarget</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1743</span> </span><span class="WHIT">    </span><span class="NAME">addEventListener</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1745</span> </span><span class="WHIT">          </span><span class="NAME">listener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">fn.call</span><span class="PUNC">(</span><span class="NAME">_self</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">window.event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1747</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1748</span> 
<span class='line'>1749</span> </span><span class="WHIT">      </span><span class="NAME">this.attachEvent</span><span class="PUNC">(</span><span class="STRN">'on'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">listener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1750</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1751</span> 
<span class='line'>1752</span> </span><span class="WHIT">    </span><span class="COMM">// Stub!</span><span class="WHIT">
<span class='line'>1753</span> </span><span class="WHIT">    </span><span class="NAME">removeEventListener</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1754</span> </span><span class="WHIT">      </span><span class="NAME">this.detachEvent</span><span class="PUNC">(</span><span class="STRN">'on'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1755</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1756</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1757</span> 
<span class='line'>1758</span> </span><span class="WHIT">  </span><span class="NAME">$.dom.Event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1759</span> </span><span class="WHIT">    </span><span class="NAME">preventDefault</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1760</span> </span><span class="WHIT">      </span><span class="NAME">this.returnValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1761</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1762</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1763</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1764</span> 
<span class='line'>1765</span> </span><span class="COMM">/**
<span class='line'>1766</span>  * @namespace Holds the list of virtual key identifiers and a few characters, 
<span class='line'>1767</span>  * each being associated to a key code commonly used by Web browsers.
<span class='line'>1768</span>  *
<span class='line'>1769</span>  * @private
<span class='line'>1770</span>  */</span><span class="WHIT">
<span class='line'>1771</span> </span><span class="NAME">$.dom.keyNames</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1772</span> </span><span class="WHIT">  </span><span class="NAME">Help</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1773</span> </span><span class="WHIT">  </span><span class="NAME">Backspace</span><span class="PUNC">:</span><span class="WHIT">     </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1774</span> </span><span class="WHIT">  </span><span class="NAME">Tab</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1775</span> </span><span class="WHIT">  </span><span class="NAME">Clear</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">12</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1776</span> </span><span class="WHIT">  </span><span class="NAME">Enter</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">13</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1777</span> </span><span class="WHIT">  </span><span class="NAME">Shift</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1778</span> </span><span class="WHIT">  </span><span class="NAME">Control</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">17</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1779</span> </span><span class="WHIT">  </span><span class="NAME">Alt</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">18</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1780</span> </span><span class="WHIT">  </span><span class="NAME">Pause</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">19</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1781</span> </span><span class="WHIT">  </span><span class="NAME">CapsLock</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">20</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1782</span> </span><span class="WHIT">  </span><span class="NAME">Cancel</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="NUMB">24</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1783</span> </span><span class="WHIT">  </span><span class="STRN">'Escape'</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">27</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1784</span> </span><span class="WHIT">  </span><span class="NAME">Space</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1785</span> </span><span class="WHIT">  </span><span class="NAME">PageUp</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="NUMB">33</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1786</span> </span><span class="WHIT">  </span><span class="NAME">PageDown</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">34</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1787</span> </span><span class="WHIT">  </span><span class="NAME">End</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">35</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1788</span> </span><span class="WHIT">  </span><span class="NAME">Home</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">36</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1789</span> </span><span class="WHIT">  </span><span class="NAME">Left</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">37</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1790</span> </span><span class="WHIT">  </span><span class="NAME">Up</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">38</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1791</span> </span><span class="WHIT">  </span><span class="NAME">Right</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NUMB">39</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1792</span> </span><span class="WHIT">  </span><span class="NAME">Down</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">40</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1793</span> </span><span class="WHIT">  </span><span class="NAME">PrintScreen</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">44</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1794</span> </span><span class="WHIT">  </span><span class="NAME">Insert</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="NUMB">45</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1795</span> </span><span class="WHIT">  </span><span class="STRN">'Delete'</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NUMB">46</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1796</span> </span><span class="WHIT">  </span><span class="NAME">Win</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">91</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1797</span> </span><span class="WHIT">  </span><span class="NAME">ContextMenu</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">93</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1798</span> </span><span class="WHIT">  </span><span class="STRN">'*'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">106</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1799</span> </span><span class="WHIT">  </span><span class="STRN">'+'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">107</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1800</span> </span><span class="WHIT">  </span><span class="NAME">F1</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">112</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1801</span> </span><span class="WHIT">  </span><span class="NAME">F2</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">113</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1802</span> </span><span class="WHIT">  </span><span class="NAME">F3</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">114</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1803</span> </span><span class="WHIT">  </span><span class="NAME">F4</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">115</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1804</span> </span><span class="WHIT">  </span><span class="NAME">F5</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">116</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1805</span> </span><span class="WHIT">  </span><span class="NAME">F6</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">117</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1806</span> </span><span class="WHIT">  </span><span class="NAME">F7</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">118</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1807</span> </span><span class="WHIT">  </span><span class="NAME">F8</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">119</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1808</span> </span><span class="WHIT">  </span><span class="NAME">F9</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">120</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1809</span> </span><span class="WHIT">  </span><span class="NAME">F10</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">121</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1810</span> </span><span class="WHIT">  </span><span class="NAME">F11</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">122</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1811</span> </span><span class="WHIT">  </span><span class="NAME">F12</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">123</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1812</span> </span><span class="WHIT">  </span><span class="NAME">NumLock</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">144</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1813</span> </span><span class="WHIT">  </span><span class="STRN">';'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">186</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1814</span> </span><span class="WHIT">  </span><span class="STRN">'='</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">187</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1815</span> </span><span class="WHIT">  </span><span class="STRN">','</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">188</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1816</span> </span><span class="WHIT">  </span><span class="STRN">'-'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">189</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1817</span> </span><span class="WHIT">  </span><span class="STRN">'.'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">190</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1818</span> </span><span class="WHIT">  </span><span class="STRN">'/'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">191</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1819</span> </span><span class="WHIT">  </span><span class="STRN">'`'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">192</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1820</span> </span><span class="WHIT">  </span><span class="STRN">'['</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">219</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1821</span> </span><span class="WHIT">  </span><span class="STRN">'\\'</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NUMB">220</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1822</span> </span><span class="WHIT">  </span><span class="STRN">']'</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">221</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1823</span> </span><span class="WHIT">  </span><span class="STRN">"'"</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="NUMB">222</span><span class="WHIT">
<span class='line'>1824</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1825</span> 
<span class='line'>1826</span> </span><span class="COMM">/**
<span class='line'>1827</span>  * @namespace Holds the list of codes, each being associated to a virtual key 
<span class='line'>1828</span>  * identifier.
<span class='line'>1829</span>  *
<span class='line'>1830</span>  * @private
<span class='line'>1831</span>  */</span><span class="WHIT">
<span class='line'>1832</span> </span><span class="NAME">$.dom.keyCodes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1833</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1834</span>    * For almost each key code, these comments give the key name, the 
<span class='line'>1835</span>    * keyIdentifier from the DOM 3 Events spec and the Unicode character 
<span class='line'>1836</span>    * information (if you would use the decimal code for direct conversion to 
<span class='line'>1837</span>    * a character, e.g. String.fromCharCode()). Obviously, the Unicode character 
<span class='line'>1838</span>    * information is not to be used, since these are only virtual key codes (not 
<span class='line'>1839</span>    * really char codes) associated to key names.
<span class='line'>1840</span>    *
<span class='line'>1841</span>    * Each key name in here tries to follow the same style as the defined 
<span class='line'>1842</span>    * keyIdentifiers from the DOM 3 Events. Thus for the Page Down button, 
<span class='line'>1843</span>    * 'PageDown' is used (not other variations like 'pag-up'), and so on.
<span class='line'>1844</span>    *
<span class='line'>1845</span>    * Multiple key codes might be associated to the same key - it's not an error.
<span class='line'>1846</span>    *
<span class='line'>1847</span>    * Note that this list is not an exhaustive key codes list. This means that 
<span class='line'>1848</span>    * for key A or for key 0, the script will do String.fromCharCode(keyCode), to 
<span class='line'>1849</span>    * determine the key. For the case of alpha-numeric keys, this works fine.
<span class='line'>1850</span>    */</span><span class="WHIT">
<span class='line'>1851</span> 
<span class='line'>1852</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1853</span>    * Key: Enter
<span class='line'>1854</span>    * Unicode: U+0003 [End of text]
<span class='line'>1855</span>    *
<span class='line'>1856</span>    * Note 1: This keyCode is only used in Safari 2 (older Webkit) for the Enter 
<span class='line'>1857</span>    * key.
<span class='line'>1858</span>    *
<span class='line'>1859</span>    * Note 2: In Gecko this keyCode is used for the Cancel key (see 
<span class='line'>1860</span>    * DOM_VK_CANCEL).
<span class='line'>1861</span>    */</span><span class="WHIT">
<span class='line'>1862</span> </span><span class="WHIT">  </span><span class="NUMB">3</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1863</span> 
<span class='line'>1864</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1865</span>    * Key: Help
<span class='line'>1866</span>    * Unicode: U+0006 [Acknowledge]
<span class='line'>1867</span>    *
<span class='line'>1868</span>    * Note: Taken from Gecko (DOM_VK_HELP).
<span class='line'>1869</span>    */</span><span class="WHIT">
<span class='line'>1870</span> </span><span class="WHIT">  </span><span class="NUMB">6</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Help'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1871</span> 
<span class='line'>1872</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1873</span>    * Key: Backspace
<span class='line'>1874</span>    * Unicode: U+0008 [Backspace]
<span class='line'>1875</span>    * keyIdentifier: U+0008
<span class='line'>1876</span>    */</span><span class="WHIT">
<span class='line'>1877</span> </span><span class="WHIT">  </span><span class="NUMB">8</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Backspace'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1878</span> 
<span class='line'>1879</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1880</span>    * Key: Tab
<span class='line'>1881</span>    * Unicode: U+0009 [Horizontal tab]
<span class='line'>1882</span>    * keyIdentifier: U+0009
<span class='line'>1883</span>    */</span><span class="WHIT">
<span class='line'>1884</span> </span><span class="WHIT">  </span><span class="NUMB">9</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Tab'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1885</span> 
<span class='line'>1886</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1887</span>    * Key: Enter
<span class='line'>1888</span>    * Unicode: U+0010 [Line feed (LF) / New line (NL) / End of line (EOL)]
<span class='line'>1889</span>    *
<span class='line'>1890</span>    * Note: Taken from the Unicode characters list. If it ends up as a keyCode in 
<span class='line'>1891</span>    * some event, it's simply considered as being the Enter key.
<span class='line'>1892</span>    */</span><span class="WHIT">
<span class='line'>1893</span> </span><span class="WHIT">  </span><span class="NUMB">10</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1894</span> 
<span class='line'>1895</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1896</span>    * Key: NumPad_Center
<span class='line'>1897</span>    * Unicode: U+000C [Form feed]
<span class='line'>1898</span>    * keyIdentifier: Clear
<span class='line'>1899</span>    *
<span class='line'>1900</span>    * Note 1: This keyCode is used when NumLock is off, and the user pressed the 
<span class='line'>1901</span>    * 5 key on the numeric pad.
<span class='line'>1902</span>    *
<span class='line'>1903</span>    * Note 2: Safari 2 (older Webkit) assigns this keyCode to the NumLock key 
<span class='line'>1904</span>    * itself.
<span class='line'>1905</span>    */</span><span class="WHIT">
<span class='line'>1906</span> </span><span class="WHIT">  </span><span class="NUMB">12</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Clear'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1907</span> 
<span class='line'>1908</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1909</span>    * Key: Enter
<span class='line'>1910</span>    * Unicode: U+000D [Carriage return (CR)]
<span class='line'>1911</span>    * keyIdentifier: Enter
<span class='line'>1912</span>    *
<span class='line'>1913</span>    * Note 1: This is the keyCode used by most of the Web browsers when the Enter 
<span class='line'>1914</span>    * key is pressed.
<span class='line'>1915</span>    *
<span class='line'>1916</span>    * Note 2: Gecko associates the DOM_VK_RETURN to this keyCode.
<span class='line'>1917</span>    */</span><span class="WHIT">
<span class='line'>1918</span> </span><span class="WHIT">  </span><span class="NUMB">13</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1919</span> 
<span class='line'>1920</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1921</span>    * Key: Enter
<span class='line'>1922</span>    * Unicode: U+000E [Shift out]
<span class='line'>1923</span>    *
<span class='line'>1924</span>    * Note: Taken from Gecko (DOM_VK_ENTER).
<span class='line'>1925</span>    */</span><span class="WHIT">
<span class='line'>1926</span> </span><span class="WHIT">  </span><span class="NUMB">14</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1927</span> 
<span class='line'>1928</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1929</span>    * Key: Shift
<span class='line'>1930</span>    * Unicode: U+0010 [Data link escape]
<span class='line'>1931</span>    * keyIdentifier: Shift
<span class='line'>1932</span>    *
<span class='line'>1933</span>    * Note: In older Safari (Webkit) versions Shift+Tab is assigned a different 
<span class='line'>1934</span>    * keyCode: keyCode 25.
<span class='line'>1935</span>    */</span><span class="WHIT">
<span class='line'>1936</span> </span><span class="WHIT">  </span><span class="NUMB">16</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Shift'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1937</span> 
<span class='line'>1938</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1939</span>    * Key: Control
<span class='line'>1940</span>    * Unicode: U+0011 [Device control one]
<span class='line'>1941</span>    * keyIdentifier: Control
<span class='line'>1942</span>    */</span><span class="WHIT">
<span class='line'>1943</span> </span><span class="WHIT">  </span><span class="NUMB">17</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Control'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1944</span> 
<span class='line'>1945</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1946</span>    * Key: Alt
<span class='line'>1947</span>    * Unicode: U+0012 [Device control two]
<span class='line'>1948</span>    * keyIdentifier: Alt
<span class='line'>1949</span>    */</span><span class="WHIT">
<span class='line'>1950</span> </span><span class="WHIT">  </span><span class="NUMB">18</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Alt'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1951</span> 
<span class='line'>1952</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1953</span>    * Key: Pause
<span class='line'>1954</span>    * Unicode: U+0013 [Device control three]
<span class='line'>1955</span>    * keyIdentifier: Pause
<span class='line'>1956</span>    */</span><span class="WHIT">
<span class='line'>1957</span> </span><span class="WHIT">  </span><span class="NUMB">19</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Pause'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1958</span> 
<span class='line'>1959</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1960</span>    * Key: CapsLock
<span class='line'>1961</span>    * Unicode: U+0014 [Device control four]
<span class='line'>1962</span>    * keyIdentifier: CapsLock
<span class='line'>1963</span>    */</span><span class="WHIT">
<span class='line'>1964</span> </span><span class="WHIT">  </span><span class="NUMB">20</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'CapsLock'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1965</span> 
<span class='line'>1966</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1967</span>    * Key: Cancel
<span class='line'>1968</span>    * Unicode: U+0018 [Cancel]
<span class='line'>1969</span>    * keyIdentifier: U+0018
<span class='line'>1970</span>    */</span><span class="WHIT">
<span class='line'>1971</span> </span><span class="WHIT">  </span><span class="NUMB">24</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Cancel'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1972</span> 
<span class='line'>1973</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1974</span>    * Key: Escape
<span class='line'>1975</span>    * Unicode: U+001B [Escape]
<span class='line'>1976</span>    * keyIdentifier: U+001B
<span class='line'>1977</span>    */</span><span class="WHIT">
<span class='line'>1978</span> </span><span class="WHIT">  </span><span class="NUMB">27</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Escape'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1979</span> 
<span class='line'>1980</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1981</span>    * Key: Space
<span class='line'>1982</span>    * Unicode: U+0020 [Space]
<span class='line'>1983</span>    * keyIdentifier: U+0020
<span class='line'>1984</span>    */</span><span class="WHIT">
<span class='line'>1985</span> </span><span class="WHIT">  </span><span class="NUMB">32</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Space'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1986</span> 
<span class='line'>1987</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1988</span>    * Key: PageUp or NumPad_North_East
<span class='line'>1989</span>    * Unicode: U+0021 ! [Exclamation mark]
<span class='line'>1990</span>    * keyIdentifier: PageUp
<span class='line'>1991</span>    */</span><span class="WHIT">
<span class='line'>1992</span> </span><span class="WHIT">  </span><span class="NUMB">33</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'PageUp'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1993</span> 
<span class='line'>1994</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>1995</span>    * Key: PageDown or NumPad_South_East
<span class='line'>1996</span>    * Unicode: U+0022 " [Quotation mark]
<span class='line'>1997</span>    * keyIdentifier: PageDown
<span class='line'>1998</span>    */</span><span class="WHIT">
<span class='line'>1999</span> </span><span class="WHIT">  </span><span class="NUMB">34</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'PageDown'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2000</span> 
<span class='line'>2001</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2002</span>    * Key: End or NumPad_South_West
<span class='line'>2003</span>    * Unicode: U+0023 # [Number sign]
<span class='line'>2004</span>    * keyIdentifier: PageDown
<span class='line'>2005</span>    */</span><span class="WHIT">
<span class='line'>2006</span> </span><span class="WHIT">  </span><span class="NUMB">35</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'End'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2007</span> 
<span class='line'>2008</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2009</span>    * Key: Home or NumPad_North_West
<span class='line'>2010</span>    * Unicode: U+0024 $ [Dollar sign]
<span class='line'>2011</span>    * keyIdentifier: Home
<span class='line'>2012</span>    */</span><span class="WHIT">
<span class='line'>2013</span> </span><span class="WHIT">  </span><span class="NUMB">36</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Home'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2014</span> 
<span class='line'>2015</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2016</span>    * Key: Left or NumPad_West
<span class='line'>2017</span>    * Unicode: U+0025 % [Percent sign]
<span class='line'>2018</span>    * keyIdentifier: Left
<span class='line'>2019</span>    */</span><span class="WHIT">
<span class='line'>2020</span> </span><span class="WHIT">  </span><span class="NUMB">37</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Left'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2021</span> 
<span class='line'>2022</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2023</span>    * Key: Up or NumPad_North
<span class='line'>2024</span>    * Unicode: U+0026 & [Ampersand]
<span class='line'>2025</span>    * keyIdentifier: Up
<span class='line'>2026</span>    */</span><span class="WHIT">
<span class='line'>2027</span> </span><span class="WHIT">  </span><span class="NUMB">38</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Up'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2028</span> 
<span class='line'>2029</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2030</span>    * Key: Right or NumPad_East
<span class='line'>2031</span>    * Unicode: U+0027 ' [Apostrophe]
<span class='line'>2032</span>    * keyIdentifier: Right
<span class='line'>2033</span>    */</span><span class="WHIT">
<span class='line'>2034</span> </span><span class="WHIT">  </span><span class="NUMB">39</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Right'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2035</span> 
<span class='line'>2036</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2037</span>    * Key: Down or NumPad_South
<span class='line'>2038</span>    * Unicode: U+0028 ( [Left parenthesis]
<span class='line'>2039</span>    * keyIdentifier: Down
<span class='line'>2040</span>    */</span><span class="WHIT">
<span class='line'>2041</span> </span><span class="WHIT">  </span><span class="NUMB">40</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Down'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2042</span> 
<span class='line'>2043</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2044</span>    * Key: PrintScreen
<span class='line'>2045</span>    * Unicode: U+002C , [Comma]
<span class='line'>2046</span>    * keyIdentifier: PrintScreen
<span class='line'>2047</span>    */</span><span class="WHIT">
<span class='line'>2048</span> </span><span class="WHIT">  </span><span class="COMM">//44: 'PrintScreen',</span><span class="WHIT">
<span class='line'>2049</span> 
<span class='line'>2050</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2051</span>    * Key: Insert or NumPad_Insert
<span class='line'>2052</span>    * Unicode: U+002D - [Hyphen-Minus]
<span class='line'>2053</span>    * keyIdentifier: Insert
<span class='line'>2054</span>    */</span><span class="WHIT">
<span class='line'>2055</span> </span><span class="WHIT">  </span><span class="NUMB">45</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Insert'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2056</span> 
<span class='line'>2057</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2058</span>    * Key: Delete or NumPad_Delete
<span class='line'>2059</span>    * Unicode: U+002E . [Full stop / period]
<span class='line'>2060</span>    * keyIdentifier: U+007F
<span class='line'>2061</span>    */</span><span class="WHIT">
<span class='line'>2062</span> </span><span class="WHIT">  </span><span class="NUMB">46</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Delete'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2063</span> 
<span class='line'>2064</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2065</span>    * Key: WinLeft
<span class='line'>2066</span>    * Unicode: U+005B [ [Left square bracket]
<span class='line'>2067</span>    * keyIdentifier: Win
<span class='line'>2068</span>    *
<span class='line'>2069</span>    * Disabled: rarely needed.
<span class='line'>2070</span>    */</span><span class="WHIT">
<span class='line'>2071</span> </span><span class="WHIT">  </span><span class="COMM">//91: 'Win',</span><span class="WHIT">
<span class='line'>2072</span> 
<span class='line'>2073</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2074</span>    * Key: WinRight
<span class='line'>2075</span>    * Unicode: U+005C \ [Reverse solidus / Backslash]
<span class='line'>2076</span>    * keyIdentifier: Win
<span class='line'>2077</span>    */</span><span class="WHIT">
<span class='line'>2078</span> </span><span class="WHIT">  </span><span class="COMM">//92: 'Win',</span><span class="WHIT">
<span class='line'>2079</span> 
<span class='line'>2080</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2081</span>    * Key: Menu/ContextMenu
<span class='line'>2082</span>    * Unicode: U+005D ] [Right square bracket]
<span class='line'>2083</span>    * keyIdentifier: ...
<span class='line'>2084</span>    *
<span class='line'>2085</span>    * Disabled: Is it Meta? Is it Menu, ContextMenu, what? Too much mess.
<span class='line'>2086</span>    */</span><span class="WHIT">
<span class='line'>2087</span> </span><span class="WHIT">  </span><span class="COMM">//93: 'ContextMenu',</span><span class="WHIT">
<span class='line'>2088</span> 
<span class='line'>2089</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2090</span>    * Key: NumPad_0
<span class='line'>2091</span>    * Unicode: U+0060 ` [Grave accent]
<span class='line'>2092</span>    * keyIdentifier: 0
<span class='line'>2093</span>    */</span><span class="WHIT">
<span class='line'>2094</span> </span><span class="WHIT">  </span><span class="NUMB">96</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'0'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2095</span> 
<span class='line'>2096</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2097</span>    * Key: NumPad_1
<span class='line'>2098</span>    * Unicode: U+0061 a [Latin small letter a]
<span class='line'>2099</span>    * keyIdentifier: 1
<span class='line'>2100</span>    */</span><span class="WHIT">
<span class='line'>2101</span> </span><span class="WHIT">  </span><span class="NUMB">97</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'1'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2102</span> 
<span class='line'>2103</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2104</span>    * Key: NumPad_2
<span class='line'>2105</span>    * Unicode: U+0062 b [Latin small letter b]
<span class='line'>2106</span>    * keyIdentifier: 2
<span class='line'>2107</span>    */</span><span class="WHIT">
<span class='line'>2108</span> </span><span class="WHIT">  </span><span class="NUMB">98</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'2'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2109</span> 
<span class='line'>2110</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2111</span>    * Key: NumPad_3
<span class='line'>2112</span>    * Unicode: U+0063 c [Latin small letter c]
<span class='line'>2113</span>    * keyIdentifier: 3
<span class='line'>2114</span>    */</span><span class="WHIT">
<span class='line'>2115</span> </span><span class="WHIT">  </span><span class="NUMB">99</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'3'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2116</span> 
<span class='line'>2117</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2118</span>    * Key: NumPad_4
<span class='line'>2119</span>    * Unicode: U+0064 d [Latin small letter d]
<span class='line'>2120</span>    * keyIdentifier: 4
<span class='line'>2121</span>    */</span><span class="WHIT">
<span class='line'>2122</span> </span><span class="WHIT">  </span><span class="NUMB">100</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'4'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2123</span> 
<span class='line'>2124</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2125</span>    * Key: NumPad_5
<span class='line'>2126</span>    * Unicode: U+0065 e [Latin small letter e]
<span class='line'>2127</span>    * keyIdentifier: 5
<span class='line'>2128</span>    */</span><span class="WHIT">
<span class='line'>2129</span> </span><span class="WHIT">  </span><span class="NUMB">101</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'5'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2130</span> 
<span class='line'>2131</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2132</span>    * Key: NumPad_6
<span class='line'>2133</span>    * Unicode: U+0066 f [Latin small letter f]
<span class='line'>2134</span>    * keyIdentifier: 6
<span class='line'>2135</span>    */</span><span class="WHIT">
<span class='line'>2136</span> </span><span class="WHIT">  </span><span class="NUMB">102</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'6'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2137</span> 
<span class='line'>2138</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2139</span>    * Key: NumPad_7
<span class='line'>2140</span>    * Unicode: U+0067 g [Latin small letter g]
<span class='line'>2141</span>    * keyIdentifier: 7
<span class='line'>2142</span>    */</span><span class="WHIT">
<span class='line'>2143</span> </span><span class="WHIT">  </span><span class="NUMB">103</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'7'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2144</span> 
<span class='line'>2145</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2146</span>    * Key: NumPad_8
<span class='line'>2147</span>    * Unicode: U+0068 h [Latin small letter h]
<span class='line'>2148</span>    * keyIdentifier: 8
<span class='line'>2149</span>    */</span><span class="WHIT">
<span class='line'>2150</span> </span><span class="WHIT">  </span><span class="NUMB">104</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'8'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2151</span> 
<span class='line'>2152</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2153</span>    * Key: NumPad_9
<span class='line'>2154</span>    * Unicode: U+0069 i [Latin small letter i]
<span class='line'>2155</span>    * keyIdentifier: 9
<span class='line'>2156</span>    */</span><span class="WHIT">
<span class='line'>2157</span> </span><span class="WHIT">  </span><span class="NUMB">105</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'9'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2158</span> 
<span class='line'>2159</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2160</span>    * Key: NumPad_Multiply
<span class='line'>2161</span>    * Unicode: U+0070 j [Latin small letter j]
<span class='line'>2162</span>    * keyIdentifier: U+002A * [Asterisk / Star]
<span class='line'>2163</span>    */</span><span class="WHIT">
<span class='line'>2164</span> </span><span class="WHIT">  </span><span class="NUMB">106</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'*'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2165</span> 
<span class='line'>2166</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2167</span>    * Key: NumPad_Plus
<span class='line'>2168</span>    * Unicode: U+0071 k [Latin small letter k]
<span class='line'>2169</span>    * keyIdentifier: U+002B + [Plus]
<span class='line'>2170</span>    */</span><span class="WHIT">
<span class='line'>2171</span> </span><span class="WHIT">  </span><span class="NUMB">107</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'+'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2172</span> 
<span class='line'>2173</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2174</span>    * Key: NumPad_Minus
<span class='line'>2175</span>    * Unicode: U+0073 m [Latin small letter m]
<span class='line'>2176</span>    * keyIdentifier: U+002D + [Hyphen / Minus]
<span class='line'>2177</span>    */</span><span class="WHIT">
<span class='line'>2178</span> </span><span class="WHIT">  </span><span class="NUMB">109</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2179</span> 
<span class='line'>2180</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2181</span>    * Key: NumPad_Period
<span class='line'>2182</span>    * Unicode: U+0074 n [Latin small letter n]
<span class='line'>2183</span>    * keyIdentifier: U+002E . [Period]
<span class='line'>2184</span>    */</span><span class="WHIT">
<span class='line'>2185</span> </span><span class="WHIT">  </span><span class="NUMB">110</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2186</span> 
<span class='line'>2187</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2188</span>    * Key: NumPad_Division
<span class='line'>2189</span>    * Unicode: U+0075 o [Latin small letter o]
<span class='line'>2190</span>    * keyIdentifier: U+002F / [Solidus / Slash]
<span class='line'>2191</span>    */</span><span class="WHIT">
<span class='line'>2192</span> </span><span class="WHIT">  </span><span class="NUMB">111</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'/'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2193</span> 
<span class='line'>2194</span> </span><span class="WHIT">  </span><span class="NUMB">112</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F1'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// p</span><span class="WHIT">
<span class='line'>2195</span> </span><span class="WHIT">  </span><span class="NUMB">113</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F2'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// q</span><span class="WHIT">
<span class='line'>2196</span> </span><span class="WHIT">  </span><span class="NUMB">114</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F3'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// r</span><span class="WHIT">
<span class='line'>2197</span> </span><span class="WHIT">  </span><span class="NUMB">115</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F4'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// s</span><span class="WHIT">
<span class='line'>2198</span> </span><span class="WHIT">  </span><span class="NUMB">116</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F5'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// t</span><span class="WHIT">
<span class='line'>2199</span> </span><span class="WHIT">  </span><span class="NUMB">117</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F6'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// u</span><span class="WHIT">
<span class='line'>2200</span> </span><span class="WHIT">  </span><span class="NUMB">118</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F7'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// v</span><span class="WHIT">
<span class='line'>2201</span> </span><span class="WHIT">  </span><span class="NUMB">119</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F8'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// w</span><span class="WHIT">
<span class='line'>2202</span> </span><span class="WHIT">  </span><span class="NUMB">120</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F9'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// x</span><span class="WHIT">
<span class='line'>2203</span> </span><span class="WHIT">  </span><span class="NUMB">121</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F10'</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// y</span><span class="WHIT">
<span class='line'>2204</span> </span><span class="WHIT">  </span><span class="NUMB">122</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F11'</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// z</span><span class="WHIT">
<span class='line'>2205</span> </span><span class="WHIT">  </span><span class="NUMB">123</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'F12'</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// {</span><span class="WHIT">
<span class='line'>2206</span> 
<span class='line'>2207</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2208</span>    * Key: Delete
<span class='line'>2209</span>    * Unicode: U+007F [Delete]
<span class='line'>2210</span>    * keyIdentifier: U+007F
<span class='line'>2211</span>    */</span><span class="WHIT">
<span class='line'>2212</span> </span><span class="WHIT">  </span><span class="NUMB">127</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Delete'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2213</span> 
<span class='line'>2214</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2215</span>    * Key: NumLock
<span class='line'>2216</span>    * Unicode: U+0090 [Device control string]
<span class='line'>2217</span>    * keyIdentifier: NumLock
<span class='line'>2218</span>    */</span><span class="WHIT">
<span class='line'>2219</span> </span><span class="WHIT">  </span><span class="NUMB">144</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'NumLock'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2220</span> 
<span class='line'>2221</span> </span><span class="WHIT">  </span><span class="NUMB">186</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">';'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// º (Masculine ordinal indicator)</span><span class="WHIT">
<span class='line'>2222</span> </span><span class="WHIT">  </span><span class="NUMB">187</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'='</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// »</span><span class="WHIT">
<span class='line'>2223</span> </span><span class="WHIT">  </span><span class="NUMB">188</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">','</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ¼</span><span class="WHIT">
<span class='line'>2224</span> </span><span class="WHIT">  </span><span class="NUMB">189</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ½</span><span class="WHIT">
<span class='line'>2225</span> </span><span class="WHIT">  </span><span class="NUMB">190</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'.'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ¾</span><span class="WHIT">
<span class='line'>2226</span> </span><span class="WHIT">  </span><span class="NUMB">191</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'/'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// ¿</span><span class="WHIT">
<span class='line'>2227</span> </span><span class="WHIT">  </span><span class="NUMB">192</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'`'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// À</span><span class="WHIT">
<span class='line'>2228</span> </span><span class="WHIT">  </span><span class="NUMB">219</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'['</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// Û</span><span class="WHIT">
<span class='line'>2229</span> </span><span class="WHIT">  </span><span class="NUMB">220</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'\\'</span><span class="PUNC">,</span><span class="WHIT">                </span><span class="COMM">// Ü</span><span class="WHIT">
<span class='line'>2230</span> </span><span class="WHIT">  </span><span class="NUMB">221</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">']'</span><span class="PUNC">,</span><span class="WHIT">                 </span><span class="COMM">// Ý</span><span class="WHIT">
<span class='line'>2231</span> </span><span class="WHIT">  </span><span class="NUMB">222</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"'"</span><span class="WHIT">                  </span><span class="COMM">// Þ (Latin capital letter thorn)</span><span class="WHIT">
<span class='line'>2232</span> 
<span class='line'>2233</span> </span><span class="WHIT">  </span><span class="COMM">//224: 'Win',               // à</span><span class="WHIT">
<span class='line'>2234</span> </span><span class="WHIT">  </span><span class="COMM">//229: 'WinIME',            // å or WinIME or something else in Webkit</span><span class="WHIT">
<span class='line'>2235</span> </span><span class="WHIT">  </span><span class="COMM">//255: 'NumLock',           // ÿ, Gecko and Chrome, Windows XP in VirtualBox</span><span class="WHIT">
<span class='line'>2236</span> </span><span class="WHIT">  </span><span class="COMM">//376: 'NumLock'            // Ÿ, Opera, Windows XP in VirtualBox</span><span class="WHIT">
<span class='line'>2237</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2238</span> 
<span class='line'>2239</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.gecko</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2240</span> </span><span class="WHIT">  </span><span class="NAME">$.dom.keyCodes</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'Cancel'</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// DOM_VK_CANCEL</span><span class="WHIT">
<span class='line'>2241</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2242</span> 
<span class='line'>2243</span> </span><span class="COMM">/**
<span class='line'>2244</span>  * @namespace Holds a list of common wrong key codes in Web browsers.
<span class='line'>2245</span>  *
<span class='line'>2246</span>  * @private
<span class='line'>2247</span>  */</span><span class="WHIT">
<span class='line'>2248</span> </span><span class="NAME">$.dom.keyCodes_fixes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2249</span> </span><span class="WHIT">  </span><span class="NUMB">42</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'*'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// char * to key *</span><span class="WHIT">
<span class='line'>2250</span> </span><span class="WHIT">  </span><span class="NUMB">47</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'/'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// char / to key /</span><span class="WHIT">
<span class='line'>2251</span> </span><span class="WHIT">  </span><span class="NUMB">59</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">';'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// char ; to key ;</span><span class="WHIT">
<span class='line'>2252</span> </span><span class="WHIT">  </span><span class="NUMB">61</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'='</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// char = to key =</span><span class="WHIT">
<span class='line'>2253</span> </span><span class="WHIT">  </span><span class="NUMB">96</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">48</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_0 to char 0</span><span class="WHIT">
<span class='line'>2254</span> </span><span class="WHIT">  </span><span class="NUMB">97</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">49</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_1 to char 1</span><span class="WHIT">
<span class='line'>2255</span> </span><span class="WHIT">  </span><span class="NUMB">98</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">50</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_2 to char 2</span><span class="WHIT">
<span class='line'>2256</span> </span><span class="WHIT">  </span><span class="NUMB">99</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NUMB">51</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_3 to char 3</span><span class="WHIT">
<span class='line'>2257</span> </span><span class="WHIT">  </span><span class="NUMB">100</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">52</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_4 to char 4</span><span class="WHIT">
<span class='line'>2258</span> </span><span class="WHIT">  </span><span class="NUMB">101</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">53</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_5 to char 5</span><span class="WHIT">
<span class='line'>2259</span> </span><span class="WHIT">  </span><span class="NUMB">102</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">54</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_6 to char 6</span><span class="WHIT">
<span class='line'>2260</span> </span><span class="WHIT">  </span><span class="NUMB">103</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">55</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_7 to char 7</span><span class="WHIT">
<span class='line'>2261</span> </span><span class="WHIT">  </span><span class="NUMB">104</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">56</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_8 to char 8</span><span class="WHIT">
<span class='line'>2262</span> </span><span class="WHIT">  </span><span class="NUMB">105</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NUMB">57</span><span class="PUNC">,</span><span class="WHIT">                             </span><span class="COMM">// NumPad_9 to char 9</span><span class="WHIT">
<span class='line'>2263</span> </span><span class="WHIT">  </span><span class="COMM">//106:  56,                           // NumPad_Multiply to char 8</span><span class="WHIT">
<span class='line'>2264</span> </span><span class="WHIT">  </span><span class="COMM">//107:  187,                          // NumPad_Plus to key =</span><span class="WHIT">
<span class='line'>2265</span> </span><span class="WHIT">  </span><span class="NUMB">109</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'-'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// NumPad_Minus to key -</span><span class="WHIT">
<span class='line'>2266</span> </span><span class="WHIT">  </span><span class="NUMB">110</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'.'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// NumPad_Period to key .</span><span class="WHIT">
<span class='line'>2267</span> </span><span class="WHIT">  </span><span class="NUMB">111</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'/'</span><span class="PUNC">]</span><span class="WHIT">             </span><span class="COMM">// NumPad_Division to key /</span><span class="WHIT">
<span class='line'>2268</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2269</span> 
<span class='line'>2270</span> </span><span class="COMM">/**
<span class='line'>2271</span>  * @namespace Holds the list of broken key codes generated by older Webkit 
<span class='line'>2272</span>  * (Safari 2).
<span class='line'>2273</span>  *
<span class='line'>2274</span>  * @private
<span class='line'>2275</span>  */</span><span class="WHIT">
<span class='line'>2276</span> </span><span class="NAME">$.dom.keyCodes_Safari2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2277</span> </span><span class="WHIT">  </span><span class="NUMB">63232</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Up</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 38</span><span class="WHIT">
<span class='line'>2278</span> </span><span class="WHIT">  </span><span class="NUMB">63233</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Down</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// 40</span><span class="WHIT">
<span class='line'>2279</span> </span><span class="WHIT">  </span><span class="NUMB">63234</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Left</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// 37</span><span class="WHIT">
<span class='line'>2280</span> </span><span class="WHIT">  </span><span class="NUMB">63235</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Right</span><span class="PUNC">,</span><span class="WHIT">            </span><span class="COMM">// 39</span><span class="WHIT">
<span class='line'>2281</span> </span><span class="WHIT">  </span><span class="NUMB">63236</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F1</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 112</span><span class="WHIT">
<span class='line'>2282</span> </span><span class="WHIT">  </span><span class="NUMB">63237</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F2</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 113</span><span class="WHIT">
<span class='line'>2283</span> </span><span class="WHIT">  </span><span class="NUMB">63238</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F3</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 114</span><span class="WHIT">
<span class='line'>2284</span> </span><span class="WHIT">  </span><span class="NUMB">63239</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F4</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 115</span><span class="WHIT">
<span class='line'>2285</span> </span><span class="WHIT">  </span><span class="NUMB">63240</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F5</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 116</span><span class="WHIT">
<span class='line'>2286</span> </span><span class="WHIT">  </span><span class="NUMB">63241</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F6</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 117</span><span class="WHIT">
<span class='line'>2287</span> </span><span class="WHIT">  </span><span class="NUMB">63242</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F7</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 118</span><span class="WHIT">
<span class='line'>2288</span> </span><span class="WHIT">  </span><span class="NUMB">63243</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F8</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 119</span><span class="WHIT">
<span class='line'>2289</span> </span><span class="WHIT">  </span><span class="NUMB">63244</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F9</span><span class="PUNC">,</span><span class="WHIT">               </span><span class="COMM">// 120</span><span class="WHIT">
<span class='line'>2290</span> </span><span class="WHIT">  </span><span class="NUMB">63245</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F10</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 121</span><span class="WHIT">
<span class='line'>2291</span> </span><span class="WHIT">  </span><span class="NUMB">63246</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F11</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 122</span><span class="WHIT">
<span class='line'>2292</span> </span><span class="WHIT">  </span><span class="NUMB">63247</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.F12</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 123</span><span class="WHIT">
<span class='line'>2293</span> </span><span class="WHIT">  </span><span class="NUMB">63248</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.PrintScreen</span><span class="PUNC">,</span><span class="WHIT">      </span><span class="COMM">// 44</span><span class="WHIT">
<span class='line'>2294</span> </span><span class="WHIT">  </span><span class="NUMB">63272</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'Delete'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">        </span><span class="COMM">// 46</span><span class="WHIT">
<span class='line'>2295</span> </span><span class="WHIT">  </span><span class="NUMB">63273</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Home</span><span class="PUNC">,</span><span class="WHIT">             </span><span class="COMM">// 36</span><span class="WHIT">
<span class='line'>2296</span> </span><span class="WHIT">  </span><span class="NUMB">63275</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.End</span><span class="PUNC">,</span><span class="WHIT">              </span><span class="COMM">// 35</span><span class="WHIT">
<span class='line'>2297</span> </span><span class="WHIT">  </span><span class="NUMB">63276</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.PageUp</span><span class="PUNC">,</span><span class="WHIT">           </span><span class="COMM">// 33</span><span class="WHIT">
<span class='line'>2298</span> </span><span class="WHIT">  </span><span class="NUMB">63277</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.PageDown</span><span class="PUNC">,</span><span class="WHIT">         </span><span class="COMM">// 34</span><span class="WHIT">
<span class='line'>2299</span> </span><span class="WHIT">  </span><span class="NUMB">63289</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.NumLock</span><span class="PUNC">,</span><span class="WHIT">          </span><span class="COMM">// 144</span><span class="WHIT">
<span class='line'>2300</span> </span><span class="WHIT">  </span><span class="NUMB">63302</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Insert</span><span class="WHIT">            </span><span class="COMM">// 45</span><span class="WHIT">
<span class='line'>2301</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2302</span> 
<span class='line'>2303</span> 
<span class='line'>2304</span> </span><span class="COMM">/**
<span class='line'>2305</span>  * A complex keyboard events cross-browser compatibility layer.
<span class='line'>2306</span>  *
<span class='line'>2307</span>  * &lt;p>Unfortunately, due to the important differences across Web browsers, 
<span class='line'>2308</span>  * simply using the available properties in a single keyboard event is not 
<span class='line'>2309</span>  * enough to accurately determine the key the user pressed. Thus, one needs to 
<span class='line'>2310</span>  * have event handlers for all keyboard-related events &lt;code>keydown&lt;/code>, 
<span class='line'>2311</span>  * &lt;code>keypress&lt;/code> and &lt;code>keyup&lt;/code>.
<span class='line'>2312</span>  *
<span class='line'>2313</span>  * &lt;p>This class provides a complete keyboard event compatibility layer. For any 
<span class='line'>2314</span>  * new instance you provide the DOM element you want to listen events for, and 
<span class='line'>2315</span>  * the event handlers for any of the three events &lt;code>keydown&lt;/code> 
<span class='line'>2316</span>  * / &lt;code>keypress&lt;/code> / &lt;code>keyup&lt;/code>.
<span class='line'>2317</span>  *
<span class='line'>2318</span>  * &lt;p>Your event handlers will receive the original DOM Event object, with 
<span class='line'>2319</span>  * several new properties defined:
<span class='line'>2320</span>  *
<span class='line'>2321</span>  * &lt;ul>
<span class='line'>2322</span>  *   &lt;li>&lt;var>event.keyCode_&lt;/var> holds the correct code for event key.
<span class='line'>2323</span>  *
<span class='line'>2324</span>  *   &lt;li>&lt;var>event.key_&lt;/var> holds the key the user pressed. It can be either 
<span class='line'>2325</span>  *   a key name like "PageDown", "Delete", "Enter", or it is a character like 
<span class='line'>2326</span>  *   "A", "1", or "[".
<span class='line'>2327</span>  *
<span class='line'>2328</span>  *   &lt;li>&lt;var>event.charCode_&lt;/var> holds the Unicode character decimal code.
<span class='line'>2329</span>  *
<span class='line'>2330</span>  *   &lt;li>&lt;var>event.char_&lt;/var> holds the character generated by the event.
<span class='line'>2331</span>  *
<span class='line'>2332</span>  *   &lt;li>&lt;var>event.repeat_&lt;/var> is a boolean property telling if the 
<span class='line'>2333</span>  *   &lt;code>keypress&lt;/code> event is repeated - the user is holding down the key 
<span class='line'>2334</span>  *   for a long-enough period of time to generate multiple events.
<span class='line'>2335</span>  * &lt;/ul>
<span class='line'>2336</span>  *
<span class='line'>2337</span>  * &lt;p>The character-related properties, &lt;var>charCode_&lt;/var> and 
<span class='line'>2338</span>  * &lt;var>char_&lt;/var> are only available in the &lt;code>keypress&lt;/code> and 
<span class='line'>2339</span>  * &lt;code>keyup&lt;/code> event objects.
<span class='line'>2340</span>  *
<span class='line'>2341</span>  * &lt;p>This class will ensure that the &lt;code>keypress&lt;/code> event is always 
<span class='line'>2342</span>  * fired in Webkit and MSIE for all keys, except modifiers. For modifier keys 
<span class='line'>2343</span>  * like &lt;kbd>Shift&lt;/kbd>, &lt;kbd>Control&lt;/kbd>, and &lt;kbd>Alt&lt;/kbd>, the 
<span class='line'>2344</span>  * &lt;code>keypress&lt;/code> event will not be fired, even if the Web browser does 
<span class='line'>2345</span>  * it.
<span class='line'>2346</span>  *
<span class='line'>2347</span>  * &lt;p>Some user agents like Webkit repeat the &lt;code>keydown&lt;/code> event while 
<span class='line'>2348</span>  * the user holds down a key. This class will ensure that only the 
<span class='line'>2349</span>  * &lt;code>keypress&lt;/code> event is repeated.
<span class='line'>2350</span>  *
<span class='line'>2351</span>  * &lt;p>If you want to prevent the default action for an event, you should prevent 
<span class='line'>2352</span>  * it on &lt;code>keypress&lt;/code>. This class will prevent the default action for 
<span class='line'>2353</span>  * &lt;code>keydown&lt;/code> if need (in MSIE).
<span class='line'>2354</span>  *
<span class='line'>2355</span>  * @example
<span class='line'>2356</span>  * &lt;code>var &lt;var>klogger&lt;/var> = function (&lt;var>ev&lt;/var>) {
<span class='line'>2357</span>  *   console.log(&lt;var>ev&lt;/var>.type +
<span class='line'>2358</span>  *     ' keyCode_ ' + &lt;var>ev&lt;/var>.keyCode_ +
<span class='line'>2359</span>  *     ' key_ ' + &lt;var>ev&lt;/var>.key_ +
<span class='line'>2360</span>  *     ' charCode_ ' + &lt;var>ev&lt;/var>.charCode_ +
<span class='line'>2361</span>  *     ' char_ ' + &lt;var>ev&lt;/var>.char_ +
<span class='line'>2362</span>  *     ' repeat_ ' + &lt;var>ev&lt;/var>.repeat_);
<span class='line'>2363</span>  * };
<span class='line'>2364</span>  *
<span class='line'>2365</span>  * var &lt;var>kbListener&lt;/var> = new $.dom.KeyboardEventListener(window,
<span class='line'>2366</span>  *               {keydown: &lt;var>klogger&lt;/var>,
<span class='line'>2367</span>  *                keypress: &lt;var>klogger&lt;/var>,
<span class='line'>2368</span>  *                keyup: &lt;var>klogger&lt;/var>});&lt;/code>
<span class='line'>2369</span>  *
<span class='line'>2370</span>  * // later when you're done...
<span class='line'>2371</span>  * &lt;code>&lt;var>kbListener&lt;/var>.detach();&lt;/code>
<span class='line'>2372</span>  *
<span class='line'>2373</span>  * @class A complex keyboard events cross-browser compatibility layer.
<span class='line'>2374</span>  *
<span class='line'>2375</span>  * @param {Element} elem_ The DOM Element you want to listen events for.
<span class='line'>2376</span>  *
<span class='line'>2377</span>  * @param {Object} handlers_ The object holding the list of event handlers 
<span class='line'>2378</span>  * associated to the name of each keyboard event you want to listen. To listen 
<span class='line'>2379</span>  * for all the three keyboard events use &lt;code>{keydown: &lt;var>fn1&lt;/var>, 
<span class='line'>2380</span>  * keypress: &lt;var>fn2&lt;/var>, keyup: &lt;var>fn3&lt;/var>}&lt;/code>.
<span class='line'>2381</span>  *
<span class='line'>2382</span>  * @throws {TypeError} If the &lt;var>handlers_&lt;/var> object does not contain any 
<span class='line'>2383</span>  * event handler.
<span class='line'>2384</span>  *
<span class='line'>2385</span>  * @see $.dom.KeyboardEvent.getKey The simpler approach to keyboard event 
<span class='line'>2386</span>  * compatibility.
<span class='line'>2387</span>  */</span><span class="WHIT">
<span class='line'>2388</span> </span><span class="NAME">$.dom.KeyboardEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handlers_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2389</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>2390</span>     Technical details:
<span class='line'>2391</span> 
<span class='line'>2392</span>     For the keyup and keydown events the keyCode provided is that of the virtual 
<span class='line'>2393</span>     key irrespective of other modifiers (e.g. Shift). Generally, during the 
<span class='line'>2394</span>     keypress event, the keyCode holds the Unicode value of the character 
<span class='line'>2395</span>     resulted from the key press, say an alphabetic upper/lower-case char, 
<span class='line'>2396</span>     depending on the actual intent of the user and depending on the currently 
<span class='line'>2397</span>     active keyboard layout.
<span class='line'>2398</span> 
<span class='line'>2399</span>     Examples:
<span class='line'>2400</span>     * Pressing p you get keyCode 80 in keyup/keydown, and keyCode 112 in 
<span class='line'>2401</span>     keypress.  String.fromCharCode(80) = 'P' and String.fromCharCode(112) = 'p'.
<span class='line'>2402</span>     * Pressing P you get keyCode 80 in all events.
<span class='line'>2403</span>     * Pressing F1 you get keyCode 112 in keyup, keydown and keypress.
<span class='line'>2404</span>     * Pressing 9 you get keyCode 57 in all events.
<span class='line'>2405</span>     * Pressing Shift+9 you get keyCode 57 in keyup/keydown, and keyCode 40 in 
<span class='line'>2406</span>     keypress. String.fromCharCode(57) = '9' and String.fromCharCode(40) = '('.
<span class='line'>2407</span> 
<span class='line'>2408</span>     * Using the Greek layout when you press v on an US keyboard you get the 
<span class='line'>2409</span>     output character ω. The keyup/keydown events hold keyCode 86 which is V.  
<span class='line'>2410</span>     This does make sense, since it's the virtual key code we are dealing with 
<span class='line'>2411</span>     - not the character code, not the result of pressing the key. The keypress 
<span class='line'>2412</span>     event will hold keyCode 969 (ω).
<span class='line'>2413</span> 
<span class='line'>2414</span>     * Pressing NumPad_Minus you get keyCode 109 in keyup/keydown and keyCode 45 
<span class='line'>2415</span>     in keypress. Again, this happens because in keyup/keydown you don't get the 
<span class='line'>2416</span>     character code, you get the key code, as indicated above. For
<span class='line'>2417</span>     your information: String.fromCharCode(109) = 'm' and String.fromCharCode(45) 
<span class='line'>2418</span>     = '-'.
<span class='line'>2419</span> 
<span class='line'>2420</span>     Therefore, we need to map all the codes of several keys, like F1-F12, 
<span class='line'>2421</span>     Escape, Enter, Tab, etc. This map is held by $.dom.keyCodes. It associates, 
<span class='line'>2422</span>     for example, code 112 to F1, or 13 to Enter. This map is used to detect 
<span class='line'>2423</span>     virtual keys in all events.
<span class='line'>2424</span> 
<span class='line'>2425</span>     (This is only the general story, details about browser-specific differences 
<span class='line'>2426</span>     follow below.)
<span class='line'>2427</span> 
<span class='line'>2428</span>     If the code given by the browser doesn't appear in keyCode maps, it's used 
<span class='line'>2429</span>     as is.  The key_ returned is that of String.fromCharCode(keyCode).
<span class='line'>2430</span> 
<span class='line'>2431</span>     In all browsers we consider all events having keyCode &lt;= 32, as being events  
<span class='line'>2432</span>     generated by a virtual key (not a character). As such, the keyCode value is 
<span class='line'>2433</span>     always searched in $.dom.keyCodes.
<span class='line'>2434</span> 
<span class='line'>2435</span>     As you might notice from the above description, in the keypress event we 
<span class='line'>2436</span>     cannot tell the difference from say F1 and p, because both give the code 
<span class='line'>2437</span>     112. In Gecko and Webkit we can tell the difference because these UAs also 
<span class='line'>2438</span>     set the charCode event property when the key generates a character. If F1 is 
<span class='line'>2439</span>     pressed, or some other virtual key, charCode is never set.
<span class='line'>2440</span> 
<span class='line'>2441</span>     In Opera the charCode property is never set. However, the 'which' event 
<span class='line'>2442</span>     property is not set for several virtual keys. This means we can tell the 
<span class='line'>2443</span>     difference between a character and a virtual key. However, there's a catch: 
<span class='line'>2444</span>     not *all* virtual keys have the 'which' property unset. Known exceptions: 
<span class='line'>2445</span>     Backspace (8), Tab (9), Enter (13), Shift (16), Control (17), Alt (18), 
<span class='line'>2446</span>     Pause (19), Escape (27), End (35), Home (36), Insert (45), Delete (46) and 
<span class='line'>2447</span>     NumLock (144). Given we already consider any keyCode &lt;= 32 being one of some 
<span class='line'>2448</span>     virtual key, fewer exceptions remain. We only have the End, Home, Insert, 
<span class='line'>2449</span>     Delete and the NumLock keys which cannot be 100% properly detected in the 
<span class='line'>2450</span>     keypress event, in Opera. To properly detect End/Home we can check if the 
<span class='line'>2451</span>     Shift modifier is active or not. If the user wants # instead of End, then 
<span class='line'>2452</span>     Shift must be active. The same goes for $ and Home. Thus we now only have 
<span class='line'>2453</span>     the '-' (Insert) and the '.' (Delete) characters incorrectly detected as 
<span class='line'>2454</span>     being Insert/Delete.
<span class='line'>2455</span>     
<span class='line'>2456</span>     The above brings us to one of the main visible difference, when comparing 
<span class='line'>2457</span>     the $.dom.KeyboardEventListener class and the simple 
<span class='line'>2458</span>     $.dom.KeyboardEvent.getKey() function. In getKey(), for the keypress event 
<span class='line'>2459</span>     we cannot accurately determine the exact key, because it requires checking
<span class='line'>2460</span>     the keyCode used for the keydown event. The KeyboardEventListener
<span class='line'>2461</span>     class monitors all the keyboard events, ensuring a more accurate key 
<span class='line'>2462</span>     detection.
<span class='line'>2463</span> 
<span class='line'>2464</span>     Different keyboard layouts and international characters are generally 
<span class='line'>2465</span>     supported. Tested and known to work with the Cyrillic alphabet (Greek 
<span class='line'>2466</span>     keyboard layout) and with the US Dvorak keyboard layouts.
<span class='line'>2467</span> 
<span class='line'>2468</span>     Opera does not fire the keyup event for international characters when 
<span class='line'>2469</span>     running on Linux. For example, this happens with the Greek keyboard layout, 
<span class='line'>2470</span>     when trying Cyrillic characters.
<span class='line'>2471</span> 
<span class='line'>2472</span>     Gecko gives no keyCode/charCode/which for international characters when 
<span class='line'>2473</span>     running on Linux, in the keyup/keydown events. Thus, all such keys remain 
<span class='line'>2474</span>     unidentified for these two events. For the keypress event there are no 
<span class='line'>2475</span>     issues with such characters.
<span class='line'>2476</span> 
<span class='line'>2477</span>     Webkit and Konqueror 4 also implement the keyIdentifier property from the 
<span class='line'>2478</span>     DOM 3 Events specification. In theory, this should be great, but it's not 
<span class='line'>2479</span>     without problems.  Sometimes keyCode/charCode/which are all 0, but 
<span class='line'>2480</span>     keyIdentifier is properly set. For several virtual keys the keyIdentifier 
<span class='line'>2481</span>     value is simply 'U+0000'. Thus, the keyIdentifier is used only if the value 
<span class='line'>2482</span>     is not 'Unidentified' / 'U+0000', and only when keyCode/charCode/which are 
<span class='line'>2483</span>     not available.
<span class='line'>2484</span> 
<span class='line'>2485</span>     Konqueror 4 does not use the 'U+XXXX' notation for Unicode characters. It 
<span class='line'>2486</span>     simply gives the character, directly.
<span class='line'>2487</span> 
<span class='line'>2488</span>     Additionally, Konqueror seems to have some problems with several keyCodes in 
<span class='line'>2489</span>     keydown/keyup. For example, the key '[' gives keyCode 91 instead of 219.  
<span class='line'>2490</span>     Thus, it effectively gives the Unicode for the character, not the key code.  
<span class='line'>2491</span>     This issue is visible with other key as well.
<span class='line'>2492</span> 
<span class='line'>2493</span>     NumPad_Clear is unidentified on Linux in all browsers, but it works on 
<span class='line'>2494</span>     Windows.
<span class='line'>2495</span> 
<span class='line'>2496</span>     In MSIE the keypress event is only fired for characters and for Escape, 
<span class='line'>2497</span>     Space and Enter. Similarly, Webkit only fires the keypress event for 
<span class='line'>2498</span>     characters. However, Webkit does not fire keypress for Escape.
<span class='line'>2499</span> 
<span class='line'>2500</span>     International characters and different keyboard layouts seem to work fine in 
<span class='line'>2501</span>     MSIE as well.
<span class='line'>2502</span> 
<span class='line'>2503</span>     As of MSIE 4.0, the keypress event fires for the following keys:
<span class='line'>2504</span>       * Letters: A - Z (uppercase and lowercase)
<span class='line'>2505</span>       * Numerals: 0 - 9
<span class='line'>2506</span>       * Symbols: ! @ # $ % ^ & * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~
<span class='line'>2507</span>       * System: Escape (27), Space (32), Enter (13)
<span class='line'>2508</span> 
<span class='line'>2509</span>     Documentation about the keypress event:
<span class='line'>2510</span>     http://msdn.microsoft.com/en-us/library/ms536939(VS.85).aspx
<span class='line'>2511</span> 
<span class='line'>2512</span>     As of MSIE 4.0, the keydown event fires for the following keys:
<span class='line'>2513</span>       * Editing: Delete (46), Insert (45)
<span class='line'>2514</span>       * Function: F1 - F12
<span class='line'>2515</span>       * Letters: A - Z (uppercase and lowercase)
<span class='line'>2516</span>       * Navigation: Home, End, Left, Right, Up, Down
<span class='line'>2517</span>       * Numerals: 0 - 9
<span class='line'>2518</span>       * Symbols: ! @ # $ % ^ & * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~
<span class='line'>2519</span>       * System: Escape (27), Space (32), Shift (16), Tab (9)
<span class='line'>2520</span> 
<span class='line'>2521</span>     As of MSIE 5, the event also fires for the following keys:
<span class='line'>2522</span>       * Editing: Backspace (8)
<span class='line'>2523</span>       * Navigation: PageUp (33), PageDown (34)
<span class='line'>2524</span>       * System: Shift+Tab (9)
<span class='line'>2525</span> 
<span class='line'>2526</span>     Documentation about the keydown event:
<span class='line'>2527</span>     http://msdn.microsoft.com/en-us/library/ms536938(VS.85).aspx
<span class='line'>2528</span> 
<span class='line'>2529</span>     As of MSIE 4.0, the keyup event fires for the following keys:
<span class='line'>2530</span>       * Editing: Delete, Insert
<span class='line'>2531</span>       * Function: F1 - F12
<span class='line'>2532</span>       * Letters: A - Z (uppercase and lowercase)
<span class='line'>2533</span>       * Navigation: Home (36), End (35), Left (37), Right (39), Up (38), Down (40)
<span class='line'>2534</span>       * Numerals: 0 - 9
<span class='line'>2535</span>       * Symbols: ! @ # $ % ^ & * ( ) _ - + = &lt; [ ] { } , . / ? \ | ' ` " ~
<span class='line'>2536</span>       * System: Escape (27), Space (32), Shift (16), Tab (9)
<span class='line'>2537</span> 
<span class='line'>2538</span>     As of MSIE 5, the event also fires for the following keys:
<span class='line'>2539</span>       * Editing: Backspace (8)
<span class='line'>2540</span>       * Navigation: PageUp (33), PageDown (34)
<span class='line'>2541</span>       * System: Shift+Tab (9)
<span class='line'>2542</span> 
<span class='line'>2543</span>     Documentation about the keyup event:
<span class='line'>2544</span>     http://msdn.microsoft.com/en-us/library/ms536940(VS.85).aspx
<span class='line'>2545</span> 
<span class='line'>2546</span>     For further gory details and a different implementation see:
<span class='line'>2547</span>     http://code.google.com/p/doctype/source/browse/trunk/goog/events/keycodes.js
<span class='line'>2548</span>     http://code.google.com/p/doctype/source/browse/trunk/goog/events/keyhandler.js
<span class='line'>2549</span> 
<span class='line'>2550</span>     Opera keydown/keyup:
<span class='line'>2551</span>       These events fire for all keys, including for modifiers.
<span class='line'>2552</span>       keyCode is always set.
<span class='line'>2553</span>       charCode is never set.
<span class='line'>2554</span>       which is always set.
<span class='line'>2555</span>       keyIdentifier is always undefined.
<span class='line'>2556</span> 
<span class='line'>2557</span>     Opera keypress:
<span class='line'>2558</span>       This event fires for all keys, except for modifiers themselves.
<span class='line'>2559</span>       keyCode is always set.
<span class='line'>2560</span>       charCode is never set.
<span class='line'>2561</span>       which is set for all characters. which = 0 for several virtual keys.
<span class='line'>2562</span>       which is known to be set for: Backspace (8), Tab (9), Enter (13), Shift 
<span class='line'>2563</span>       (16), Control (17), Alt (18), Pause (19), Escape (27), End (35), Home 
<span class='line'>2564</span>       (36), Insert (45), Delete (46), NumLock (144).
<span class='line'>2565</span>       which is known to be unset for: F1 - F12, PageUp (33), PageDown (34), Left 
<span class='line'>2566</span>       (37), Up (38), Right (39), Down (40).
<span class='line'>2567</span>       keyIdentifier is always undefined.
<span class='line'>2568</span> 
<span class='line'>2569</span>     MSIE keyup/keypress/keydown:
<span class='line'>2570</span>       Event firing conditions are described above.
<span class='line'>2571</span>       keyCode is always set.
<span class='line'>2572</span>       charCode is never set.
<span class='line'>2573</span>       which is never set.
<span class='line'>2574</span>       keyIdentifier is always undefined.
<span class='line'>2575</span> 
<span class='line'>2576</span>     Webkit keydown/keyup:
<span class='line'>2577</span>       These events fires for all keys, including for modifiers.
<span class='line'>2578</span>       keyCode is always set.
<span class='line'>2579</span>       charCode is never set.
<span class='line'>2580</span>       which is always set.
<span class='line'>2581</span>       keyIdentifier is always set.
<span class='line'>2582</span> 
<span class='line'>2583</span>     Webkit keypress:
<span class='line'>2584</span>       This event fires for characters keys, similarly to MSIE (see above info).
<span class='line'>2585</span>       keyCode is always set.
<span class='line'>2586</span>       charCode is always set for all characters.
<span class='line'>2587</span>       which is always set.
<span class='line'>2588</span>       keyIdentifier is null.
<span class='line'>2589</span> 
<span class='line'>2590</span>     Gecko keydown/keyup:
<span class='line'>2591</span>       These events fire for all keys, including for modifiers.
<span class='line'>2592</span>       keyCode is always set.
<span class='line'>2593</span>       charCode is never set.
<span class='line'>2594</span>       which is always set.
<span class='line'>2595</span>       keyIdentifier is always undefined.
<span class='line'>2596</span> 
<span class='line'>2597</span>     Gecko keypress:
<span class='line'>2598</span>       This event fires for all keys, except for modifiers themselves.
<span class='line'>2599</span>       keyCode is only set for virtual keys, not for characters.
<span class='line'>2600</span>       charCode is always set for all characters.
<span class='line'>2601</span>       which is always set for all characters and for the Enter virtual key.
<span class='line'>2602</span>       keyIdentifier is always undefined.
<span class='line'>2603</span> 
<span class='line'>2604</span>     Another important difference between the KeyboardEventListener class and the 
<span class='line'>2605</span>     getKey() function is that the class tries to ensure that the keypress event 
<span class='line'>2606</span>     is fired for the handler, even if the Web browser does not do it natively.  
<span class='line'>2607</span>     Also, the class tries to provide a consistent approach to keyboard event 
<span class='line'>2608</span>     repetition when the user holds down a key for longer periods of time, by 
<span class='line'>2609</span>     repeating only the keypress event.
<span class='line'>2610</span> 
<span class='line'>2611</span>     On Linux, Opera, Firefox and Konqueror do not repeat the keydown event, only 
<span class='line'>2612</span>     keypress. On Windows, Opera, Firefox and MSIE do repeat the keydown and 
<span class='line'>2613</span>     keypress events while the user holds down the key. Webkit  repeats the 
<span class='line'>2614</span>     keydown and the keypress (when it fires) events on both systems.
<span class='line'>2615</span> 
<span class='line'>2616</span>     The default action can be prevented for during keydown in MSIE, and during 
<span class='line'>2617</span>     keypress for the other browsers. In Webkit when keypress doesn't fire, 
<span class='line'>2618</span>     keydown needs to be prevented.
<span class='line'>2619</span> 
<span class='line'>2620</span>     The KeyboardEventListener class tries to bring consistency. The keydown 
<span class='line'>2621</span>     event never repeats, only the keypress event repeats and it always fires for 
<span class='line'>2622</span>     all keys. The keypress event never fires for modifiers. Events should always 
<span class='line'>2623</span>     be prevented during keypress - the class deals with preventing the event 
<span class='line'>2624</span>     during keydown or keypress as needed in Webkit and MSIE.
<span class='line'>2625</span> 
<span class='line'>2626</span>     If no code/keyIdentifier is given by the browser, the getKey() function 
<span class='line'>2627</span>     returns null. In the case of the KeyboardEventListener class, keyCode_ 
<span class='line'>2628</span>     / key_ / charCode_ / char_ will be null or undefined.
<span class='line'>2629</span>    */</span><span class="WHIT">
<span class='line'>2630</span> 
<span class='line'>2631</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2632</span>    * During a keyboard event flow, this holds the current key code, starting 
<span class='line'>2633</span>    * from the &lt;code>keydown&lt;/code> event.
<span class='line'>2634</span>    *
<span class='line'>2635</span>    * @private
<span class='line'>2636</span>    * @type Number
<span class='line'>2637</span>    */</span><span class="WHIT">
<span class='line'>2638</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2639</span> 
<span class='line'>2640</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2641</span>    * During a keyboard event flow, this holds the current key, starting from the 
<span class='line'>2642</span>    * &lt;code>keydown&lt;/code> event.
<span class='line'>2643</span>    *
<span class='line'>2644</span>    * @private
<span class='line'>2645</span>    * @type String
<span class='line'>2646</span>    */</span><span class="WHIT">
<span class='line'>2647</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2648</span> 
<span class='line'>2649</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2650</span>    * During a keyboard event flow, this holds the current character code, 
<span class='line'>2651</span>    * starting from the &lt;code>keypress&lt;/code> event.
<span class='line'>2652</span>    *
<span class='line'>2653</span>    * @private
<span class='line'>2654</span>    * @type Number
<span class='line'>2655</span>    */</span><span class="WHIT">
<span class='line'>2656</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2657</span> 
<span class='line'>2658</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2659</span>    * During a keyboard event flow, this holds the current character, starting 
<span class='line'>2660</span>    * from the &lt;code>keypress&lt;/code> event.
<span class='line'>2661</span>    *
<span class='line'>2662</span>    * @private
<span class='line'>2663</span>    * @type String
<span class='line'>2664</span>    */</span><span class="WHIT">
<span class='line'>2665</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2666</span> 
<span class='line'>2667</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2668</span>    * True if the current keyboard event is repeating. This happens when the user 
<span class='line'>2669</span>    * holds down a key for longer periods of time.
<span class='line'>2670</span>    *
<span class='line'>2671</span>    * @private
<span class='line'>2672</span>    * @type Boolean
<span class='line'>2673</span>    */</span><span class="WHIT">
<span class='line'>2674</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2675</span> 
<span class='line'>2676</span> 
<span class='line'>2677</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">handlers_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2678</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The first argument must be of type an object.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2679</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2680</span> 
<span class='line'>2681</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">handlers_.keydown</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">handlers_.keypress</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">handlers_.keyup</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2682</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The provided handlers object has no keyboard event'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>2683</span> </span><span class="WHIT">        </span><span class="STRN">'handler.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2684</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2685</span> 
<span class='line'>2686</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handlers_.keydown</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handlers_.keydown</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2687</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The keydown event handler is not a function!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2688</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2689</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handlers_.keypress</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handlers_.keypress</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2690</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The keypress event handler is not a function!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2691</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2692</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handlers_.keyup</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">handlers_.keyup</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2693</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TypeError</span><span class="PUNC">(</span><span class="STRN">'The keyup event handler is not a function!'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2694</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2695</span> 
<span class='line'>2696</span> 
<span class='line'>2697</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2698</span>    * Attach the keyboard event listeners to the current DOM element.
<span class='line'>2699</span>    */</span><span class="WHIT">
<span class='line'>2700</span> </span><span class="WHIT">  </span><span class="NAME">this.attach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2701</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2702</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2703</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2704</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2705</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2706</span> 
<span class='line'>2707</span> </span><span class="WHIT">    </span><span class="COMM">// FIXME: I have some ideas for a solution to the problem of having multiple </span><span class="WHIT">
<span class='line'>2708</span> </span><span class="WHIT">    </span><span class="COMM">// event handlers like these attached to the same element. Only one should </span><span class="WHIT">
<span class='line'>2709</span> </span><span class="WHIT">    </span><span class="COMM">// do all the needed work.</span><span class="WHIT">
<span class='line'>2710</span> 
<span class='line'>2711</span> </span><span class="WHIT">    </span><span class="NAME">elem_.addEventListener</span><span class="PUNC">(</span><span class="STRN">'keydown'</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="NAME">keydown</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2712</span> </span><span class="WHIT">    </span><span class="NAME">elem_.addEventListener</span><span class="PUNC">(</span><span class="STRN">'keypress'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keypress</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2713</span> </span><span class="WHIT">    </span><span class="NAME">elem_.addEventListener</span><span class="PUNC">(</span><span class="STRN">'keyup'</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="NAME">keyup</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2714</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2715</span> 
<span class='line'>2716</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2717</span>    * Detach the keyboard event listeners from the current DOM element.
<span class='line'>2718</span>    */</span><span class="WHIT">
<span class='line'>2719</span> </span><span class="WHIT">  </span><span class="NAME">this.detach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2720</span> </span><span class="WHIT">    </span><span class="NAME">elem_.removeEventListener</span><span class="PUNC">(</span><span class="STRN">'keydown'</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="NAME">keydown</span><span class="PUNC">,</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2721</span> </span><span class="WHIT">    </span><span class="NAME">elem_.removeEventListener</span><span class="PUNC">(</span><span class="STRN">'keypress'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keypress</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2722</span> </span><span class="WHIT">    </span><span class="NAME">elem_.removeEventListener</span><span class="PUNC">(</span><span class="STRN">'keyup'</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="NAME">keyup</span><span class="PUNC">,</span><span class="WHIT">    </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2723</span> 
<span class='line'>2724</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2725</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2726</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2727</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2728</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2729</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2730</span> 
<span class='line'>2731</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2732</span>    * Dispatch an event.
<span class='line'>2733</span>    *
<span class='line'>2734</span>    * &lt;p>This function simply invokes the handler for the event of the given 
<span class='line'>2735</span>    * &lt;var>type&lt;/var>. The handler receives the &lt;var>ev&lt;/var> event.
<span class='line'>2736</span>    *
<span class='line'>2737</span>    * @private
<span class='line'>2738</span>    *
<span class='line'>2739</span>    * @param {String} type The event type to dispatch.
<span class='line'>2740</span>    * @param {Event} ev The DOM Event object to dispatch to the handler.
<span class='line'>2741</span>    */</span><span class="WHIT">
<span class='line'>2742</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">dispatch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2743</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">handlers_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2744</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2745</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2746</span> 
<span class='line'>2747</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">handlers_</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2748</span> 
<span class='line'>2749</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">ev.type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2750</span> </span><span class="WHIT">      </span><span class="NAME">handler.call</span><span class="PUNC">(</span><span class="NAME">elem_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2751</span> 
<span class='line'>2752</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2753</span> </span><span class="WHIT">      </span><span class="COMM">// This happens when the keydown event tries to dispatch a keypress event.</span><span class="WHIT">
<span class='line'>2754</span> 
<span class='line'>2755</span> </span><span class="WHIT">      </span><span class="COMM">// FIXME: I could use createEvent() ... food for thought for later</span><span class="WHIT">
<span class='line'>2756</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ev_new</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2757</span> </span><span class="WHIT">      </span><span class="NAME">$.extend</span><span class="PUNC">(</span><span class="NAME">ev_new</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2758</span> </span><span class="WHIT">      </span><span class="NAME">ev_new.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2759</span> 
<span class='line'>2760</span> </span><span class="WHIT">      </span><span class="COMM">// Make sure preventDefault() is not borked...</span><span class="WHIT">
<span class='line'>2761</span> </span><span class="WHIT">      </span><span class="NAME">ev_new.preventDefault</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2762</span> </span><span class="WHIT">        </span><span class="NAME">ev.preventDefault</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2763</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2764</span> 
<span class='line'>2765</span> </span><span class="WHIT">      </span><span class="NAME">handler.call</span><span class="PUNC">(</span><span class="NAME">elem_</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev_new</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2766</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2767</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2768</span> 
<span class='line'>2769</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2770</span>    * The &lt;code>keydown&lt;/code> event handler. This function determines the key 
<span class='line'>2771</span>    * pressed by the user, and checks if the &lt;code>keypress&lt;/code> event will 
<span class='line'>2772</span>    * fire in the current Web browser, or not. If it does not, a synthetic 
<span class='line'>2773</span>    * &lt;code>keypress&lt;/code> event will be fired.
<span class='line'>2774</span>    *
<span class='line'>2775</span>    * @private
<span class='line'>2776</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2777</span>    */</span><span class="WHIT">
<span class='line'>2778</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">keydown</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2779</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">prevKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2780</span> 
<span class='line'>2781</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2782</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2783</span> 
<span class='line'>2784</span> </span><span class="WHIT">    </span><span class="NAME">findKeyCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2785</span> 
<span class='line'>2786</span> </span><span class="WHIT">    </span><span class="NAME">ev.keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2787</span> </span><span class="WHIT">    </span><span class="NAME">ev.key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2788</span> </span><span class="WHIT">    </span><span class="NAME">ev.repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">prevKey</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2789</span> 
<span class='line'>2790</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.repeat_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2791</span> 
<span class='line'>2792</span> </span><span class="WHIT">    </span><span class="COMM">// When the user holds down a key for a longer period of time, the keypress </span><span class="WHIT">
<span class='line'>2793</span> </span><span class="WHIT">    </span><span class="COMM">// event is generally repeated. However, in some user agents like Webkit </span><span class="WHIT">
<span class='line'>2794</span> </span><span class="WHIT">    </span><span class="COMM">// keydown is repeated (and keypress if it fires keypress for the key). As </span><span class="WHIT">
<span class='line'>2795</span> </span><span class="WHIT">    </span><span class="COMM">// such, we do not dispatch the keydown event when a key event starts to be </span><span class="WHIT">
<span class='line'>2796</span> </span><span class="WHIT">    </span><span class="COMM">// repeated.</span><span class="WHIT">
<span class='line'>2797</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">repeat_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2798</span> </span><span class="WHIT">      </span><span class="NAME">dispatch</span><span class="PUNC">(</span><span class="STRN">'keydown'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2799</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2800</span> 
<span class='line'>2801</span> </span><span class="WHIT">    </span><span class="COMM">// MSIE and Webkit only fire the keypress event for characters </span><span class="WHIT">
<span class='line'>2802</span> </span><span class="WHIT">    </span><span class="COMM">// (alpha-numeric and symbols).</span><span class="WHIT">
<span class='line'>2803</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isModifierKey</span><span class="PUNC">(</span><span class="NAME">key_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">firesKeyPress</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2804</span> </span><span class="WHIT">      </span><span class="NAME">ev.type_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'keydown'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2805</span> </span><span class="WHIT">      </span><span class="NAME">keypress</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2806</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2807</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2808</span> 
<span class='line'>2809</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2810</span>    * The &lt;code>keypress&lt;/code> event handler. This function determines the 
<span class='line'>2811</span>    * character generated by the keyboard event.
<span class='line'>2812</span>    *
<span class='line'>2813</span>    * @private
<span class='line'>2814</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2815</span>    */</span><span class="WHIT">
<span class='line'>2816</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">keypress</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2817</span> </span><span class="WHIT">    </span><span class="COMM">// We reuse the keyCode_/key_ from the keydown event, because ev.keyCode </span><span class="WHIT">
<span class='line'>2818</span> </span><span class="WHIT">    </span><span class="COMM">// generally holds the character code during the keypress event.</span><span class="WHIT">
<span class='line'>2819</span> </span><span class="WHIT">    </span><span class="COMM">// However, if keyCode_ is not available, try to determine the key for this </span><span class="WHIT">
<span class='line'>2820</span> </span><span class="WHIT">    </span><span class="COMM">// event as well.</span><span class="WHIT">
<span class='line'>2821</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">keyCode_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2822</span> </span><span class="WHIT">      </span><span class="NAME">findKeyCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2823</span> </span><span class="WHIT">      </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2824</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2825</span> 
<span class='line'>2826</span> </span><span class="WHIT">    </span><span class="NAME">ev.keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2827</span> </span><span class="WHIT">    </span><span class="NAME">ev.key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2828</span> 
<span class='line'>2829</span> </span><span class="WHIT">    </span><span class="NAME">findCharCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2830</span> 
<span class='line'>2831</span> </span><span class="WHIT">    </span><span class="NAME">ev.charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2832</span> </span><span class="WHIT">    </span><span class="NAME">ev.char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">char_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2833</span> 
<span class='line'>2834</span> </span><span class="WHIT">    </span><span class="COMM">// Any subsequent keypress event is considered a repeated keypress (the user </span><span class="WHIT">
<span class='line'>2835</span> </span><span class="WHIT">    </span><span class="COMM">// is holding down the key).</span><span class="WHIT">
<span class='line'>2836</span> </span><span class="WHIT">    </span><span class="NAME">ev.repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">repeat_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2837</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">repeat_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2838</span> </span><span class="WHIT">      </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2839</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2840</span> 
<span class='line'>2841</span> </span><span class="WHIT">    </span><span class="COMM">// All keys should dispatch a keypress event, except the modifiers.</span><span class="WHIT">
<span class='line'>2842</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isModifierKey</span><span class="PUNC">(</span><span class="NAME">key_</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2843</span> </span><span class="WHIT">      </span><span class="NAME">dispatch</span><span class="PUNC">(</span><span class="STRN">'keypress'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2844</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2845</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2846</span> 
<span class='line'>2847</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2848</span>    * The &lt;code>keyup&lt;/code> event handler.
<span class='line'>2849</span>    *
<span class='line'>2850</span>    * @private
<span class='line'>2851</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2852</span>    */</span><span class="WHIT">
<span class='line'>2853</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">keyup</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2854</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>2855</span>      * Try to determine the keyCode_ for keyup again, even if we might already 
<span class='line'>2856</span>      * have it from keydown. This is needed because the user might press some 
<span class='line'>2857</span>      * key which only generates the keydown and keypress events, after which 
<span class='line'>2858</span>      * a sudden keyup event is fired for a completely different key.
<span class='line'>2859</span>      *
<span class='line'>2860</span>      * Example: in Opera press F2 then Escape. It will first generate two 
<span class='line'>2861</span>      * events, keydown and keypress, for the F2 key. When you press Escape to 
<span class='line'>2862</span>      * close the dialog box, the script receives keyup for Escape.
<span class='line'>2863</span>      */</span><span class="WHIT">
<span class='line'>2864</span> </span><span class="WHIT">    </span><span class="NAME">findKeyCode</span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2865</span> 
<span class='line'>2866</span> </span><span class="WHIT">    </span><span class="NAME">ev.keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2867</span> </span><span class="WHIT">    </span><span class="NAME">ev.key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2868</span> 
<span class='line'>2869</span> </span><span class="WHIT">    </span><span class="COMM">// Provide the character info from the keypress event in keyup as well.</span><span class="WHIT">
<span class='line'>2870</span> </span><span class="WHIT">    </span><span class="NAME">ev.charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charCode_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2871</span> </span><span class="WHIT">    </span><span class="NAME">ev.char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">char_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2872</span> 
<span class='line'>2873</span> </span><span class="WHIT">    </span><span class="NAME">dispatch</span><span class="PUNC">(</span><span class="STRN">'keyup'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ev</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2874</span> 
<span class='line'>2875</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2876</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2877</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2878</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2879</span> </span><span class="WHIT">    </span><span class="NAME">repeat_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2880</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2881</span> 
<span class='line'>2882</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2883</span>    * Tells if the &lt;var>key&lt;/var> is a modifier or not.
<span class='line'>2884</span>    *
<span class='line'>2885</span>    * @private
<span class='line'>2886</span>    * @param {String} key The key name.
<span class='line'>2887</span>    * @returns {Boolean} True if the &lt;var>key&lt;/var> is a modifier, or false if 
<span class='line'>2888</span>    * not.
<span class='line'>2889</span>    */</span><span class="WHIT">
<span class='line'>2890</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isModifierKey</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2891</span> </span><span class="WHIT">    </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2892</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Shift'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2893</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Control'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2894</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Alt'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2895</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Meta'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2896</span> </span><span class="WHIT">      </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'Win'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2897</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2898</span> </span><span class="WHIT">      </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2899</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2900</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2901</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2902</span> 
<span class='line'>2903</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2904</span>    * Tells if the current Web browser will fire the &lt;code>keypress&lt;/code> event 
<span class='line'>2905</span>    * for the current &lt;code>keydown&lt;/code> event object.
<span class='line'>2906</span>    *
<span class='line'>2907</span>    * @private
<span class='line'>2908</span>    *
<span class='line'>2909</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2910</span>    *
<span class='line'>2911</span>    * @returns {Boolean} True if the Web browser will fire 
<span class='line'>2912</span>    * a &lt;code>keypress&lt;/code> event, or false if not.
<span class='line'>2913</span>    */</span><span class="WHIT">
<span class='line'>2914</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">firesKeyPress</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2915</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">$.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">$.browser.webkit</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2916</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2917</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2918</span> 
<span class='line'>2919</span> </span><span class="WHIT">    </span><span class="COMM">// Check if the key is a character key, or not.</span><span class="WHIT">
<span class='line'>2920</span> </span><span class="WHIT">    </span><span class="COMM">// If it's not a character, then keypress will not fire.</span><span class="WHIT">
<span class='line'>2921</span> </span><span class="WHIT">    </span><span class="COMM">// Known exceptions: keypress fires for Space, Enter and Escape in MSIE.</span><span class="WHIT">
<span class='line'>2922</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'Space'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'Enter'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'Escape'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>2923</span>         </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2924</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2925</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2926</span> 
<span class='line'>2927</span> </span><span class="WHIT">    </span><span class="COMM">// Webkit doesn't fire keypress for Escape as well ...</span><span class="WHIT">
<span class='line'>2928</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.webkit</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Escape'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2929</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2930</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2931</span> 
<span class='line'>2932</span> </span><span class="WHIT">    </span><span class="COMM">// MSIE does not fire keypress if you hold Control / Alt down, while Shift </span><span class="WHIT">
<span class='line'>2933</span> </span><span class="WHIT">    </span><span class="COMM">// is off. Albeit, based on testing I am not completely sure if Shift needs </span><span class="WHIT">
<span class='line'>2934</span> </span><span class="WHIT">    </span><span class="COMM">// to be down or not. Sometimes MSIE won't fire keypress even if I hold </span><span class="WHIT">
<span class='line'>2935</span> </span><span class="WHIT">    </span><span class="COMM">// Shift down, and sometimes it does. Eh.</span><span class="WHIT">
<span class='line'>2936</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ev.shiftKey</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.ctrlKey</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.altKey</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2937</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2938</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2939</span> 
<span class='line'>2940</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2941</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2942</span> 
<span class='line'>2943</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>2944</span>    * Determine the key and the key code for the current DOM Event object. This 
<span class='line'>2945</span>    * function updates the &lt;var>keyCode_&lt;/var> and the &lt;var>key_&lt;/var> variables 
<span class='line'>2946</span>    * to hold the result.
<span class='line'>2947</span>    *
<span class='line'>2948</span>    * @private
<span class='line'>2949</span>    * @param {Event} ev The DOM Event object.
<span class='line'>2950</span>    */</span><span class="WHIT">
<span class='line'>2951</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">findKeyCode</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2952</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>2953</span>      * If the event has no keyCode/which/keyIdentifier values, then simply do 
<span class='line'>2954</span>      * not overwrite any existing keyCode_/key_.
<span class='line'>2955</span>      */</span><span class="WHIT">
<span class='line'>2956</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'keyup'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">ev.which</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">ev.keyIdentifier</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>2957</span>           </span><span class="NAME">ev.keyIdentifier</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.keyIdentifier</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2958</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2959</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2960</span> 
<span class='line'>2961</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2962</span> </span><span class="WHIT">    </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2963</span> 
<span class='line'>2964</span> </span><span class="WHIT">    </span><span class="COMM">// Try to use keyCode/which.</span><span class="WHIT">
<span class='line'>2965</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2966</span> </span><span class="WHIT">      </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2967</span> 
<span class='line'>2968</span> </span><span class="WHIT">      </span><span class="COMM">// Fix Webkit quirks</span><span class="WHIT">
<span class='line'>2969</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.webkit</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2970</span> </span><span class="WHIT">        </span><span class="COMM">// Old Webkit gives keyCode 25 when Shift+Tab is used.</span><span class="WHIT">
<span class='line'>2971</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">25</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.shiftKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2972</span> </span><span class="WHIT">          </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Tab</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2973</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">63232</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes_Safari2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2974</span> </span><span class="WHIT">          </span><span class="COMM">// Old Webkit gives wrong values for several keys.</span><span class="WHIT">
<span class='line'>2975</span> </span><span class="WHIT">          </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes_Safari2</span><span class="PUNC">[</span><span class="NAME">keyCode_</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2976</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2977</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2978</span> 
<span class='line'>2979</span> </span><span class="WHIT">      </span><span class="COMM">// Fix keyCode quirks in all browsers.</span><span class="WHIT">
<span class='line'>2980</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes_fixes</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2981</span> </span><span class="WHIT">        </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes_fixes</span><span class="PUNC">[</span><span class="NAME">keyCode_</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2982</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2983</span> 
<span class='line'>2984</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">keyCode_</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">keyCode_</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2985</span> 
<span class='line'>2986</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2987</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2988</span> 
<span class='line'>2989</span> </span><span class="WHIT">    </span><span class="COMM">// Try to use ev.keyIdentifier. This is only available in Webkit and </span><span class="WHIT">
<span class='line'>2990</span> </span><span class="WHIT">    </span><span class="COMM">// Konqueror 4, each having some quirks. Sometimes the property is needed, </span><span class="WHIT">
<span class='line'>2991</span> </span><span class="WHIT">    </span><span class="COMM">// because keyCode/which are not always available.</span><span class="WHIT">
<span class='line'>2992</span> 
<span class='line'>2993</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2994</span> </span><span class="WHIT">        </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2995</span> </span><span class="WHIT">        </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyIdentifier</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2996</span> 
<span class='line'>2997</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2998</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2999</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3000</span> 
<span class='line'>3001</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'U+'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3002</span> </span><span class="WHIT">      </span><span class="COMM">// Webkit gives character codes using the 'U+XXXX' notation, as per spec.</span><span class="WHIT">
<span class='line'>3003</span> </span><span class="WHIT">      </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3004</span> 
<span class='line'>3005</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3006</span> </span><span class="WHIT">      </span><span class="COMM">// Konqueror 4 implements keyIdentifier, and they provide the Unicode </span><span class="WHIT">
<span class='line'>3007</span> </span><span class="WHIT">      </span><span class="COMM">// character directly, instead of using the 'U+XXXX' notation.</span><span class="WHIT">
<span class='line'>3008</span> </span><span class="WHIT">      </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3009</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3010</span> 
<span class='line'>3011</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3012</span> </span><span class="WHIT">      </span><span class="COMM">/*
<span class='line'>3013</span>        * Common keyIdentifiers like 'PageDown' are used as they are.
<span class='line'>3014</span>        * We determine the common keyCode used by Web browsers, from the 
<span class='line'>3015</span>        * $.dom.keyNames object.
<span class='line'>3016</span>        */</span><span class="WHIT">
<span class='line'>3017</span> </span><span class="WHIT">      </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3018</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3019</span> 
<span class='line'>3020</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3021</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3022</span> 
<span class='line'>3023</span> </span><span class="WHIT">    </span><span class="COMM">// Some keyIdentifiers like 'U+007F' (127: Delete) need to become key names.</span><span class="WHIT">
<span class='line'>3024</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">127</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="WHIT"> 
<span class='line'>3025</span>           </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">144</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3026</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">keyCode</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3027</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3028</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3029</span> </span><span class="WHIT">        </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3030</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3031</span> 
<span class='line'>3032</span> </span><span class="WHIT">      </span><span class="COMM">// Konqueror gives lower-case chars</span><span class="WHIT">
<span class='line'>3033</span> </span><span class="WHIT">      </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key.toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3034</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3035</span> </span><span class="WHIT">        </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3036</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3037</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3038</span> 
<span class='line'>3039</span> </span><span class="WHIT">    </span><span class="COMM">// Correct the keyCode, make sure it's a common keyCode, not the Unicode </span><span class="WHIT">
<span class='line'>3040</span> </span><span class="WHIT">    </span><span class="COMM">// decimal representation of the character.</span><span class="WHIT">
<span class='line'>3041</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'Delete'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3042</span> </span><span class="WHIT">      </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="NAME">key_</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3043</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3044</span> 
<span class='line'>3045</span> </span><span class="WHIT">    </span><span class="NAME">keyCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3046</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3047</span> 
<span class='line'>3048</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3049</span>    * Determine the character and the character code for the current DOM Event 
<span class='line'>3050</span>    * object. This function updates the &lt;var>charCode_&lt;/var> and the 
<span class='line'>3051</span>    * &lt;var>char_&lt;/var> variables to hold the result.
<span class='line'>3052</span>    *
<span class='line'>3053</span>    * @private
<span class='line'>3054</span>    * @param {Event} ev The DOM Event object.
<span class='line'>3055</span>    */</span><span class="WHIT">
<span class='line'>3056</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">findCharCode</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3057</span> </span><span class="WHIT">    </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3058</span> </span><span class="WHIT">    </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3059</span> 
<span class='line'>3060</span> </span><span class="WHIT">    </span><span class="COMM">// Webkit and Gecko implement ev.charCode.</span><span class="WHIT">
<span class='line'>3061</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.charCode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3062</span> </span><span class="WHIT">      </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.charCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3063</span> </span><span class="WHIT">      </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">ev.charCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3064</span> 
<span class='line'>3065</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3066</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3067</span> 
<span class='line'>3068</span> </span><span class="WHIT">    </span><span class="COMM">// Try the keyCode mess.</span><span class="WHIT">
<span class='line'>3069</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3070</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ev.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3071</span> 
<span class='line'>3072</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3073</span> 
<span class='line'>3074</span> </span><span class="WHIT">      </span><span class="COMM">// We accept some keyCodes.</span><span class="WHIT">
<span class='line'>3075</span> </span><span class="WHIT">      </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3076</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Tab</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3077</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Enter</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3078</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Space</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>3079</span> </span><span class="WHIT">          </span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3080</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3081</span> 
<span class='line'>3082</span> </span><span class="WHIT">      </span><span class="COMM">// Do not consider the keyCode a character code, if during the keydown </span><span class="WHIT">
<span class='line'>3083</span> </span><span class="WHIT">      </span><span class="COMM">// event it was determined the key does not generate a character, unless </span><span class="WHIT">
<span class='line'>3084</span> </span><span class="WHIT">      </span><span class="COMM">// it's Tab, Enter or Space.</span><span class="WHIT">
<span class='line'>3085</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">force</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3086</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3087</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3088</span> 
<span class='line'>3089</span> </span><span class="WHIT">      </span><span class="COMM">// If the keypress event at hand is synthetically dispatched by keydown, </span><span class="WHIT">
<span class='line'>3090</span> </span><span class="WHIT">      </span><span class="COMM">// then special treatment is needed. This happens only in Webkit and MSIE.</span><span class="WHIT">
<span class='line'>3091</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ev.type_</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'keydown'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3092</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">keyCode</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3093</span> </span><span class="WHIT">        </span><span class="COMM">// Check if the keyCode points to a single character.</span><span class="WHIT">
<span class='line'>3094</span> </span><span class="WHIT">        </span><span class="COMM">// If it does, use it.</span><span class="WHIT">
<span class='line'>3095</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3096</span> </span><span class="WHIT">          </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// keyCodes != charCodes</span><span class="WHIT">
<span class='line'>3097</span> </span><span class="WHIT">          </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3098</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3099</span> 
<span class='line'>3100</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">force</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3101</span> </span><span class="WHIT">        </span><span class="COMM">// For normal keypress events, we are done.</span><span class="WHIT">
<span class='line'>3102</span> </span><span class="WHIT">        </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">keyCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3103</span> </span><span class="WHIT">        </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">keyCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3104</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3105</span> 
<span class='line'>3106</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">charCode_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3107</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3108</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3109</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3110</span> 
<span class='line'>3111</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>3112</span>      * Webkit and Konqueror do not provide a keyIdentifier in the keypress 
<span class='line'>3113</span>      * event, as per spec. However, in the unlikely case when the keyCode is 
<span class='line'>3114</span>      * missing, and the keyIdentifier is available, we use it.
<span class='line'>3115</span>      *
<span class='line'>3116</span>      * This property might be used when a synthetic keypress event is generated 
<span class='line'>3117</span>      * by the keydown event, and keyCode/charCode/which are all not available.
<span class='line'>3118</span>      */</span><span class="WHIT">
<span class='line'>3119</span> 
<span class='line'>3120</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3121</span> </span><span class="WHIT">        </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3122</span> </span><span class="WHIT">        </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ev.keyIdentifier</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3123</span> 
<span class='line'>3124</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>3125</span> </span><span class="WHIT">        </span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'U+'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">id.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3126</span> 
<span class='line'>3127</span> </span><span class="WHIT">      </span><span class="COMM">// Characters in Konqueror...</span><span class="WHIT">
<span class='line'>3128</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3129</span> </span><span class="WHIT">        </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3130</span> </span><span class="WHIT">        </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3131</span> 
<span class='line'>3132</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3133</span> </span><span class="WHIT">        </span><span class="COMM">// Webkit uses the 'U+XXXX' notation as per spec.</span><span class="WHIT">
<span class='line'>3134</span> </span><span class="WHIT">        </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">id.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3135</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3136</span> 
<span class='line'>3137</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Tab</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>3138</span> </span><span class="WHIT">          </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Enter</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>3139</span> </span><span class="WHIT">          </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">127</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>3140</span> </span><span class="WHIT">          </span><span class="NAME">charCode</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.NumLock</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3141</span> 
<span class='line'>3142</span> </span><span class="WHIT">        </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">charCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3143</span> </span><span class="WHIT">        </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">charCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3144</span> 
<span class='line'>3145</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3146</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3147</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3148</span> 
<span class='line'>3149</span> </span><span class="WHIT">    </span><span class="COMM">// Try to use the key determined from the previous keydown event, if it </span><span class="WHIT">
<span class='line'>3150</span> </span><span class="WHIT">    </span><span class="COMM">// holds a character.</span><span class="WHIT">
<span class='line'>3151</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key_</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key_.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3152</span> </span><span class="WHIT">      </span><span class="NAME">charCode_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3153</span> </span><span class="WHIT">      </span><span class="NAME">char_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3154</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3155</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3156</span> 
<span class='line'>3157</span> </span><span class="WHIT">  </span><span class="NAME">this.attach</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3158</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3159</span> 
<span class='line'>3160</span> </span><span class="COMM">/**
<span class='line'>3161</span>  * Holds a DOM Keyboard Event method which provides a simple way to determine 
<span class='line'>3162</span>  * the key the user pressed.
<span class='line'>3163</span>  *
<span class='line'>3164</span>  * &lt;p>By default, the global &lt;var>KeyboardEvent.prototype&lt;/var> object is 
<span class='line'>3165</span>  * extended to contain the method defined in this namespace. If the 
<span class='line'>3166</span>  * &lt;var>KeyboardEvent&lt;/var> object is not available in the browser, then the 
<span class='line'>3167</span>  * &lt;var>Event.prototype&lt;/var> object is extended.
<span class='line'>3168</span>  *
<span class='line'>3169</span>  * &lt;p>The &lt;code>getKey()&lt;/code> method uses the &lt;var>this&lt;/var> object to refer 
<span class='line'>3170</span>  * to the current event. As such, you need to pass the correct &lt;var>this&lt;/var> 
<span class='line'>3171</span>  * object.
<span class='line'>3172</span>  *
<span class='line'>3173</span>  * &lt;p>In the examples provided we will assume that the objects defined are 
<span class='line'>3174</span>  * already extended. Thus, code like &lt;code>&lt;var>ev&lt;/var>.getKey()&lt;/code> can be 
<span class='line'>3175</span>  * written directly.
<span class='line'>3176</span>  *
<span class='line'>3177</span>  * &lt;p>For more advanced keyboard event handling needs, please check out the 
<span class='line'>3178</span>  * {@link $.dom.KeyboardEventListener} class.
<span class='line'>3179</span>  *
<span class='line'>3180</span>  * @example
<span class='line'>3181</span>  * &lt;code>var &lt;var>klogger&lt;/var> = function (&lt;var>ev&lt;/var>) {
<span class='line'>3182</span>  *   console.log(&lt;var>ev&lt;/var>.type + ' key ' + &lt;var>ev&lt;/var>.getKey());
<span class='line'>3183</span>  * };
<span class='line'>3184</span>  *
<span class='line'>3185</span>  * window.addEventListener('keydown',  &lt;var>klogger&lt;/var>, false);
<span class='line'>3186</span>  * window.addEventListener('keypress', &lt;var>klogger&lt;/var>, false);
<span class='line'>3187</span>  * window.addEventListener('keyup',    &lt;var>klogger&lt;/var>, false);&lt;/code>
<span class='line'>3188</span>  *
<span class='line'>3189</span>  * @namespace Holds a DOM Keyboard Event method which provides a simple way to 
<span class='line'>3190</span>  * determine the key the user pressed.
<span class='line'>3191</span>  */</span><span class="WHIT">
<span class='line'>3192</span> </span><span class="NAME">$.dom.KeyboardEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3193</span> 
<span class='line'>3194</span> </span><span class="COMM">/**
<span class='line'>3195</span>  * This method returns the character / key identifier for the current keyboard 
<span class='line'>3196</span>  * event.
<span class='line'>3197</span>  *
<span class='line'>3198</span>  * &lt;p>Some of the key identifiers this method returns are listed in the &lt;a 
<span class='line'>3199</span>  * href="http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set">DOM 
<span class='line'>3200</span>  * 3 Events specification&lt;/a>. The notable differences are that this method 
<span class='line'>3201</span>  * uses names for several of the Unicode characters in that list:
<span class='line'>3202</span>  *
<span class='line'>3203</span>  * &lt;ul>
<span class='line'>3204</span>  *   &lt;li>'U+0008' = 'Backspace'
<span class='line'>3205</span>  *   &lt;li>'U+0009' = 'Tab'
<span class='line'>3206</span>  *   &lt;li>'U+0018' = 'Cancel'
<span class='line'>3207</span>  *   &lt;li>'U+001B' = 'Escape'
<span class='line'>3208</span>  *   &lt;li>'U+0020' = 'Space'
<span class='line'>3209</span>  *   &lt;li>'U+007F' = 'Delete'
<span class='line'>3210</span>  * &lt;/ul>
<span class='line'>3211</span>  *
<span class='line'>3212</span>  * &lt;p>Additionally, all Unicode characters of the form 'U+XXXX' are converted to 
<span class='line'>3213</span>  * the actual character. For example 'U+0053' becomes 'S'.
<span class='line'>3214</span>  *
<span class='line'>3215</span>  * &lt;p>This method is known to work in Opera, Firefox, Chrome, Safari, MSIE 
<span class='line'>3216</span>  * 8 and Konqueror.
<span class='line'>3217</span>  *
<span class='line'>3218</span>  * &lt;p>For more advanced keyboard event handling, please check {@link 
<span class='line'>3219</span>  * $.dom.KeyboardEventListener}.
<span class='line'>3220</span>  *
<span class='line'>3221</span>  * @example
<span class='line'>3222</span>  * &lt;code>var &lt;var>dialog_keydown&lt;/var> = function (&lt;var>ev&lt;/var>) {
<span class='line'>3223</span>  *   var &lt;var>key&lt;/var> = &lt;var>ev&lt;/var>.getKey();
<span class='line'>3224</span>  *   if (&lt;var>key&lt;/var> == 'F1') {
<span class='line'>3225</span>  *     // show help
<span class='line'>3226</span>  *   } else if (&lt;var>key&lt;/var> == 'Escape') {
<span class='line'>3227</span>  *     // close dialog
<span class='line'>3228</span>  *   } else if (&lt;var>key&lt;/var> == 'Enter') {
<span class='line'>3229</span>  *     // accept changes and close dialog
<span class='line'>3230</span>  *   }
<span class='line'>3231</span>  * };
<span class='line'>3232</span>  *
<span class='line'>3233</span>  * window.addEventListener('keydown', &lt;var>dialog_keydown&lt;/var>, false);&lt;/code>
<span class='line'>3234</span>  *
<span class='line'>3235</span>  * @returns {String} The character / key identifier for the current keyboard 
<span class='line'>3236</span>  * event. If the key is unrecognized null is returned.
<span class='line'>3237</span>  *
<span class='line'>3238</span>  * @see $.dom.KeyboardEventListener The more advanced keyboard event 
<span class='line'>3239</span>  * compatibility layer.
<span class='line'>3240</span>  */</span><span class="WHIT">
<span class='line'>3241</span> </span><span class="NAME">$.dom.KeyboardEvent.getKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3242</span> </span><span class="WHIT">  </span><span class="COMM">// Use any existing key_/char_ property that might have been already generated </span><span class="WHIT">
<span class='line'>3243</span> </span><span class="WHIT">  </span><span class="COMM">// by the "advanced" keyboard event handler.</span><span class="WHIT">
<span class='line'>3244</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.key_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.char_</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3245</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.key_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.char_</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3246</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3247</span> 
<span class='line'>3248</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.keyIdentifier</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3249</span> </span><span class="WHIT">      </span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3250</span> </span><span class="WHIT">      </span><span class="NAME">Unidentified</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3251</span> </span><span class="WHIT">      </span><span class="NAME">allow_keyId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3252</span> 
<span class='line'>3253</span> </span><span class="WHIT">  </span><span class="COMM">// We allow the use of keyIdentifier only if no keyCode/charCode/which is </span><span class="WHIT">
<span class='line'>3254</span> </span><span class="WHIT">  </span><span class="COMM">// available, as a 'backup'.</span><span class="WHIT">
<span class='line'>3255</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.keyCode</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">this.charCode</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">this.which</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3256</span> </span><span class="WHIT">    </span><span class="NAME">allow_keyId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3257</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3258</span> 
<span class='line'>3259</span> </span><span class="WHIT">  </span><span class="COMM">// Check if the browser implements DOM 3 Events keyIdentifier.</span><span class="WHIT">
<span class='line'>3260</span> </span><span class="WHIT">  </span><span class="COMM">// Currently, only Webkit and Konqueror implement this, albeit with some </span><span class="WHIT">
<span class='line'>3261</span> </span><span class="WHIT">  </span><span class="COMM">// errors. For now it will report 'U+0000' for some virtual keys (like Alt).</span><span class="WHIT">
<span class='line'>3262</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">allow_keyId</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'Unidentified'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'U+0000'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3263</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3264</span> 
<span class='line'>3265</span> </span><span class="WHIT">    </span><span class="COMM">// Unicode character, as per spec (in Webkit).</span><span class="WHIT">
<span class='line'>3266</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'U+'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3267</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">key.substr</span><span class="PUNC">(</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3268</span> 
<span class='line'>3269</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3270</span> </span><span class="WHIT">      </span><span class="COMM">// The character is directly provided by Konqueror, without using the </span><span class="WHIT">
<span class='line'>3271</span> </span><span class="WHIT">      </span><span class="COMM">// 'U+XXXX' notation.</span><span class="WHIT">
<span class='line'>3272</span> </span><span class="WHIT">      </span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3273</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key.charCodeAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3274</span> 
<span class='line'>3275</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3276</span> </span><span class="WHIT">      </span><span class="COMM">// Use the keyIdentifier as is. We consider it's a key name like </span><span class="WHIT">
<span class='line'>3277</span> </span><span class="WHIT">      </span><span class="COMM">// 'PageDown', 'Pause', etc.</span><span class="WHIT">
<span class='line'>3278</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3279</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3280</span> 
<span class='line'>3281</span> </span><span class="WHIT">    </span><span class="COMM">// All codes below 32 are virtual keys, as well as code 127 (the Delete </span><span class="WHIT">
<span class='line'>3282</span> </span><span class="WHIT">    </span><span class="COMM">// key).</span><span class="WHIT">
<span class='line'>3283</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">127</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">144</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3284</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3285</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3286</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">c</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3287</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3288</span> 
<span class='line'>3289</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3290</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3291</span> 
<span class='line'>3292</span> </span><span class="WHIT">  </span><span class="COMM">// Opera never uses charCode. However, it does set the .which property, when </span><span class="WHIT">
<span class='line'>3293</span> </span><span class="WHIT">  </span><span class="COMM">// a character key is pressed. This only happens for the 'keypress' event.</span><span class="WHIT">
<span class='line'>3294</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.which</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'keypress'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">$.browser.presto</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3295</span> </span><span class="WHIT">    </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3296</span> 
<span class='line'>3297</span> </span><span class="WHIT">    </span><span class="COMM">/*
<span class='line'>3298</span>      * Exceptions: Backspace (8), Tab (9), Enter (13), Shift (16), Control 
<span class='line'>3299</span>      * (17), Alt (18), Pause (19), Escape (27), End (35), Home (36), Insert 
<span class='line'>3300</span>      * (45), Delete (46) and NumLock (144).
<span class='line'>3301</span>      *
<span class='line'>3302</span>      * Here we only make an exception for End, Home, Insert, Delete and 
<span class='line'>3303</span>      * NumLock. The other key codes are automatically considered virtual keys, 
<span class='line'>3304</span>      * because keyCode &lt;= 32.
<span class='line'>3305</span>      *
<span class='line'>3306</span>      * An additional requirement is for the user to not have the Shift key 
<span class='line'>3307</span>      * modifier active. This helps telling the difference between the 
<span class='line'>3308</span>      * character # and key End (both having code 35), and character $ and key 
<span class='line'>3309</span>      * Home (both having code 36).
<span class='line'>3310</span>      */</span><span class="WHIT">
<span class='line'>3311</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.shiftKey</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>3312</span> </span><span class="WHIT">        </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.End</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Home</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>3313</span> </span><span class="WHIT">        </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Insert</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'Delete'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>3314</span> </span><span class="WHIT">        </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.NumLock</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3315</span> </span><span class="WHIT">      </span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3316</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3317</span> 
<span class='line'>3318</span> </span><span class="WHIT">  </span><span class="COMM">// Gecko always sets charCode for characters.</span><span class="WHIT">
<span class='line'>3319</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.charCode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3320</span> </span><span class="WHIT">    </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.charCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3321</span> </span><span class="WHIT">    </span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3322</span> 
<span class='line'>3323</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3324</span> </span><span class="WHIT">    </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.keyCode</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.which</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3325</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3326</span> 
<span class='line'>3327</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3328</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Unidentified</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3329</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3330</span> 
<span class='line'>3331</span> </span><span class="WHIT">  </span><span class="COMM">// MSIE does not fire the keypress event for virtual keys, with the </span><span class="WHIT">
<span class='line'>3332</span> </span><span class="WHIT">  </span><span class="COMM">// exception of Enter (13), Escape (27) and Space (32). Thus, we consider </span><span class="WHIT">
<span class='line'>3333</span> </span><span class="WHIT">  </span><span class="COMM">// all such key codes as character codes in the keypress event.</span><span class="WHIT">
<span class='line'>3334</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'keypress'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>3335</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Enter</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Space</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>3336</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames</span><span class="PUNC">[</span><span class="STRN">'Escape'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3337</span> </span><span class="WHIT">    </span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3338</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3339</span> 
<span class='line'>3340</span> </span><span class="WHIT">  </span><span class="COMM">// Keys from code 32 to lower should not be considered chars.</span><span class="WHIT">
<span class='line'>3341</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">is_char</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3342</span> </span><span class="WHIT">    </span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3343</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3344</span> 
<span class='line'>3345</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.webkit</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3346</span> </span><span class="WHIT">    </span><span class="COMM">// Old Webkit gives keyCode 25 when Shift+Tab is used.</span><span class="WHIT">
<span class='line'>3347</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">25</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.shiftKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3348</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyNames.Tab</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3349</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">63232</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes_Safari2</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3350</span> </span><span class="WHIT">      </span><span class="COMM">// Old Webkit gives wrong values for several keys.</span><span class="WHIT">
<span class='line'>3351</span> </span><span class="WHIT">      </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes_Safari2</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3352</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3353</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3354</span> 
<span class='line'>3355</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">res</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.keyCodes</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3356</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">is_char</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">res</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3357</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">String.fromCharCode</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toUpperCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3358</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3359</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">res</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3360</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3361</span> 
<span class='line'>3362</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Unidentified</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3363</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3364</span> 
<span class='line'>3365</span> 
<span class='line'>3366</span> </span><span class="COMM">/**
<span class='line'>3367</span>  * Creates a new DOMTokenList object.
<span class='line'>3368</span>  *
<span class='line'>3369</span>  * &lt;p>The &lt;a 
<span class='line'>3370</span>  * href="http://www.whatwg.org/specs/web-apps/current-work/#domtokenlist">DOMTokenList 
<span class='line'>3371</span>  * interface&lt;/a> is defined by the HTML 5 specification.  It is used for all 
<span class='line'>3372</span>  * HTMLElements for the new classList property, and for other properties on 
<span class='line'>3373</span>  * other HTML elements.
<span class='line'>3374</span>  *
<span class='line'>3375</span>  * &lt;p>This library implements the DOMTokenList interface, to be used in Web 
<span class='line'>3376</span>  * browsers which do not have it natively implemented. The level of the 
<span class='line'>3377</span>  * implementation should be close to a native one, in terms of usage from other 
<span class='line'>3378</span>  * scripts. However, it's slower and might have some "gotchas" in corner-cases.
<span class='line'>3379</span>  *
<span class='line'>3380</span>  * @example
<span class='line'>3381</span>  * // Let's work with the list of class names for the document body.
<span class='line'>3382</span>  * &lt;code>var &lt;var>elem&lt;/var> = document.body;
<span class='line'>3383</span>  * var &lt;var>list&lt;/var> = new $.dom.DOMTokenList(&lt;var>elem&lt;/var>, 'className');
<span class='line'>3384</span>  * &lt;var>list&lt;/var>.add('test');
<span class='line'>3385</span>  * &lt;var>list&lt;/var>.add('test2');
<span class='line'>3386</span>  * &lt;var>list&lt;/var>[0]; // returns 'test'
<span class='line'>3387</span>  * &lt;var>list&lt;/var>.length; // returns 2
<span class='line'>3388</span>  * &lt;var>elem&lt;/var>.className; // returns 'test test2'
<span class='line'>3389</span>  * &lt;var>list&lt;/var>.toggle('test2'); // returns false
<span class='line'>3390</span>  * &lt;var>list&lt;/var>.has('test2'); // returns false
<span class='line'>3391</span>  * &lt;var>list&lt;/var>.has('test'); // returns true
<span class='line'>3392</span>  * &lt;var>list&lt;/var>.remove('test');&lt;/code>
<span class='line'>3393</span>  *
<span class='line'>3394</span>  * @class Represents a DOMTokenList object.
<span class='line'>3395</span>  *
<span class='line'>3396</span>  * @param {HTMLElement} elem The element you want the DOMTokenList object for.
<span class='line'>3397</span>  * @param {String} attr The attribute you want the DOMTokenList for.
<span class='line'>3398</span>  *
<span class='line'>3399</span>  * @returns {DOMTokenList} The DOMTokenList object.
<span class='line'>3400</span>  */</span><span class="WHIT">
<span class='line'>3401</span> </span><span class="NAME">$.dom.DOMTokenList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3402</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_self</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3403</span> 
<span class='line'>3404</span> </span><span class="WHIT">  </span><span class="COMM">/*
<span class='line'>3405</span>    * Note: the implementation can have some "gotchas". For example:
<span class='line'>3406</span>    * elem.className = 'ana maria'
<span class='line'>3407</span>    * cl = elem.classList
<span class='line'>3408</span>    * cl[0] and cl[1] are available
<span class='line'>3409</span>    * elem.className = 'michael john'
<span class='line'>3410</span>    * cl[0] and cl[1] still hold the old values. They are updated only when the 
<span class='line'>3411</span>    * classList object is constructed, and when any of its methods are used (e.g.  
<span class='line'>3412</span>    * item(), add(), remove(), has(), toggle(), toString()).
<span class='line'>3413</span>    */</span><span class="WHIT">
<span class='line'>3414</span> 
<span class='line'>3415</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3416</span>    * @private
<span class='line'>3417</span>    */</span><span class="WHIT">
<span class='line'>3418</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">update</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3419</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3420</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3421</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3422</span> </span><span class="WHIT">    </span><span class="NAME">list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3423</span> </span><span class="WHIT">    </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3424</span> 
<span class='line'>3425</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp_tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3426</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">tmp_tokens</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3427</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3428</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3429</span> 
<span class='line'>3430</span> </span><span class="WHIT">    </span><span class="NAME">tmp_tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp_tokens.replace</span><span class="PUNC">(</span><span class="REGX">/\s+/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">trim</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3431</span> 
<span class='line'>3432</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tmp_tokens</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3433</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3434</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3435</span> 
<span class='line'>3436</span> </span><span class="WHIT">    </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tmp_tokens</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3437</span> 
<span class='line'>3438</span> </span><span class="WHIT">    </span><span class="COMM">// remove any duplicate tokens</span><span class="WHIT">
<span class='line'>3439</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tmp_list</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tokens.split</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3440</span> </span><span class="WHIT">    </span><span class="NAME">tmp_list.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3441</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">list.indexOf</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3442</span> </span><span class="WHIT">        </span><span class="NAME">list.push</span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3443</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3444</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3445</span> 
<span class='line'>3446</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">list.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">tmp_list.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3447</span> </span><span class="WHIT">      </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">elem</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list.join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3448</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3449</span> 
<span class='line'>3450</span> </span><span class="WHIT">    </span><span class="NAME">update_indexes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3451</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3452</span> 
<span class='line'>3453</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3454</span>    * @private
<span class='line'>3455</span>    */</span><span class="WHIT">
<span class='line'>3456</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">update_indexes</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3457</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">max</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Math.max</span><span class="PUNC">(</span><span class="NAME">len</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">list.length</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3458</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">max</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3459</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">list</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3460</span> </span><span class="WHIT">        </span><span class="NAME">_self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3461</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3462</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">_self</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3463</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3464</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3465</span> 
<span class='line'>3466</span> </span><span class="WHIT">    </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3467</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3468</span> 
<span class='line'>3469</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3470</span>    * The number of tokens in the current list.
<span class='line'>3471</span>    *
<span class='line'>3472</span>    * @type Number
<span class='line'>3473</span>    */</span><span class="WHIT">
<span class='line'>3474</span> </span><span class="WHIT">  </span><span class="NAME">this.length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3475</span> 
<span class='line'>3476</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3477</span> </span><span class="WHIT">  </span><span class="NAME">this.__defineGetter__</span><span class="PUNC">(</span><span class="STRN">'length'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3478</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3479</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">list.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3480</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3481</span> 
<span class='line'>3482</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3483</span>    * Retrieve the &lt;var>index&lt;/var>th token.
<span class='line'>3484</span>    *
<span class='line'>3485</span>    * @param {Number} index The zero-based index/position of the token you want.
<span class='line'>3486</span>    *
<span class='line'>3487</span>    * @returns {String} The token found at the &lt;var>index&lt;/var> position in the 
<span class='line'>3488</span>    * list.
<span class='line'>3489</span>    */</span><span class="WHIT">
<span class='line'>3490</span> </span><span class="WHIT">  </span><span class="NAME">this.item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3491</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3492</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">list</span><span class="PUNC">[</span><span class="NAME">index</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3493</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3494</span> 
<span class='line'>3495</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3496</span>    * Check if the &lt;var>token&lt;/var> is in the current list.
<span class='line'>3497</span>    *
<span class='line'>3498</span>    * @param {String} token The token you want to check.
<span class='line'>3499</span>    *
<span class='line'>3500</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If &lt;var>token&lt;/var> 
<span class='line'>3501</span>    * contains a space character.
<span class='line'>3502</span>    *
<span class='line'>3503</span>    * @returns {Boolean} True is returned if the &lt;var>token&lt;/var> was found in 
<span class='line'>3504</span>    * the current list, otherwise false is returned.
<span class='line'>3505</span>    */</span><span class="WHIT">
<span class='line'>3506</span> </span><span class="WHIT">  </span><span class="NAME">this.has</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3507</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3508</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3509</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3510</span> 
<span class='line'>3511</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token.indexOf</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3512</span> </span><span class="WHIT">      </span><span class="COMM">// This should be DOMException.INVALID_CHARACTER_ERR, but...</span><span class="WHIT">
<span class='line'>3513</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"The token must not contain spaces."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3514</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3515</span> 
<span class='line'>3516</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3517</span> 
<span class='line'>3518</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">list.indexOf</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3519</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3520</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3521</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3522</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3523</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3524</span> 
<span class='line'>3525</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3526</span>    * Add the &lt;var>token&lt;/var> to the current list.
<span class='line'>3527</span>    *
<span class='line'>3528</span>    * @param {String} token The token you want to add.
<span class='line'>3529</span>    *
<span class='line'>3530</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If &lt;var>token&lt;/var> 
<span class='line'>3531</span>    * contains a space character.
<span class='line'>3532</span>    */</span><span class="WHIT">
<span class='line'>3533</span> </span><span class="WHIT">  </span><span class="NAME">this.add</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3534</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3535</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3536</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3537</span> 
<span class='line'>3538</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token.indexOf</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3539</span> </span><span class="WHIT">      </span><span class="COMM">// This should be DOMException.INVALID_CHARACTER_ERR, but...</span><span class="WHIT">
<span class='line'>3540</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"The token must not contain spaces."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3541</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3542</span> 
<span class='line'>3543</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3544</span> 
<span class='line'>3545</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">list.indexOf</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3546</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3547</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3548</span> 
<span class='line'>3549</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3550</span> </span><span class="WHIT">      </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3551</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3552</span> 
<span class='line'>3553</span> </span><span class="WHIT">    </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3554</span> </span><span class="WHIT">    </span><span class="NAME">list.push</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3555</span> </span><span class="WHIT">    </span><span class="KEYW">this</span><span class="PUNC">[</span><span class="NAME">len</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">token</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3556</span> </span><span class="WHIT">    </span><span class="NAME">len</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3557</span> 
<span class='line'>3558</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3559</span> </span><span class="WHIT">      </span><span class="NAME">elem</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3560</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3561</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3562</span> 
<span class='line'>3563</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3564</span>    * Remove the &lt;var>token&lt;/var> from the current list.
<span class='line'>3565</span>    *
<span class='line'>3566</span>    * @param {String} token The token you want to remove.
<span class='line'>3567</span>    *
<span class='line'>3568</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If &lt;var>token&lt;/var> 
<span class='line'>3569</span>    * contains a space character.
<span class='line'>3570</span>    */</span><span class="WHIT">
<span class='line'>3571</span> </span><span class="WHIT">  </span><span class="NAME">this.remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3572</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3573</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3574</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3575</span> 
<span class='line'>3576</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token.indexOf</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3577</span> </span><span class="WHIT">      </span><span class="COMM">// This should be DOMException.INVALID_CHARACTER_ERR, but...</span><span class="WHIT">
<span class='line'>3578</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"The token must not contain spaces."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3579</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3580</span> 
<span class='line'>3581</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3582</span> 
<span class='line'>3583</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list.indexOf</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3584</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3585</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3586</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3587</span> 
<span class='line'>3588</span> </span><span class="WHIT">    </span><span class="NAME">list.splice</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3589</span> </span><span class="WHIT">    </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list.join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3590</span> </span><span class="WHIT">    </span><span class="NAME">update_indexes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3591</span> 
<span class='line'>3592</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3593</span> </span><span class="WHIT">      </span><span class="NAME">elem</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3594</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3595</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3596</span> 
<span class='line'>3597</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3598</span>    * Toggle the presence of &lt;var>token&lt;/var> in the current list.
<span class='line'>3599</span>    *
<span class='line'>3600</span>    * &lt;p>If the &lt;var>token&lt;/var> is found in the current list, it is removed.  
<span class='line'>3601</span>    * Otherwise, the &lt;var>token&lt;/var> is added.
<span class='line'>3602</span>    *
<span class='line'>3603</span>    * @param {String} token The token you want to add/remove.
<span class='line'>3604</span>    *
<span class='line'>3605</span>    * @throws {DOMException.INVALID_CHARACTER_ERR|Error} If &lt;var>token&lt;/var> 
<span class='line'>3606</span>    * contains a space character.
<span class='line'>3607</span>    *
<span class='line'>3608</span>    * @returns {Boolean} True is returned if the &lt;var>token&lt;/var> was added.  
<span class='line'>3609</span>    * Otherwise, false is returned.
<span class='line'>3610</span>    */</span><span class="WHIT">
<span class='line'>3611</span> </span><span class="WHIT">  </span><span class="NAME">this.toggle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3612</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">token</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3613</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3614</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3615</span> 
<span class='line'>3616</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">token.indexOf</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3617</span> </span><span class="WHIT">      </span><span class="COMM">// This should be DOMException.INVALID_CHARACTER_ERR, but...</span><span class="WHIT">
<span class='line'>3618</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"The token must not contain spaces."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3619</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3620</span> 
<span class='line'>3621</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3622</span> 
<span class='line'>3623</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list.indexOf</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3624</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3625</span> </span><span class="WHIT">      </span><span class="NAME">list.push</span><span class="PUNC">(</span><span class="NAME">token</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3626</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3627</span> </span><span class="WHIT">      </span><span class="NAME">list.splice</span><span class="PUNC">(</span><span class="NAME">pos</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3628</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3629</span> 
<span class='line'>3630</span> </span><span class="WHIT">    </span><span class="NAME">tokens</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">list.join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3631</span> </span><span class="WHIT">    </span><span class="NAME">update_indexes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3632</span> 
<span class='line'>3633</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">attr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3634</span> </span><span class="WHIT">      </span><span class="NAME">elem</span><span class="PUNC">[</span><span class="NAME">attr</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3635</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3636</span> 
<span class='line'>3637</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3638</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3639</span> 
<span class='line'>3640</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3641</span>    * Convert the current list to a string. All the tokens are separated by 
<span class='line'>3642</span>    * a space character, something like "token1 token2 tokenn".
<span class='line'>3643</span>    *
<span class='line'>3644</span>    * @returns {String} The list of tokens, separated by a space character.
<span class='line'>3645</span>    */</span><span class="WHIT">
<span class='line'>3646</span> </span><span class="WHIT">  </span><span class="NAME">this.toString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3647</span> </span><span class="WHIT">    </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3648</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">list.join</span><span class="PUNC">(</span><span class="STRN">' '</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3649</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3650</span> 
<span class='line'>3651</span> </span><span class="WHIT">  </span><span class="NAME">update</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3652</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3653</span> 
<span class='line'>3654</span> </span><span class="COMM">/**
<span class='line'>3655</span>  * @namespace Holds the HTMLElement-related methods.
<span class='line'>3656</span>  */</span><span class="WHIT">
<span class='line'>3657</span> </span><span class="NAME">$.dom.HTMLElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3658</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>3659</span>    * The classList property.
<span class='line'>3660</span>    *
<span class='line'>3661</span>    * &lt;p>Any HTML element will have the classList property. This allows you to 
<span class='line'>3662</span>    * quickly add/remove/read the list of class names associated with the 
<span class='line'>3663</span>    * element.
<span class='line'>3664</span>    *
<span class='line'>3665</span>    * @example
<span class='line'>3666</span>    * &lt;code>var &lt;var>elem&lt;/var> = document.body;
<span class='line'>3667</span>    * &lt;var>elem&lt;/var>.classList.add('test');
<span class='line'>3668</span>    * &lt;var>elem&lt;/var>.classList.add('test2');
<span class='line'>3669</span>    * &lt;var>elem&lt;/var>.classList[0]; // returns 'test'
<span class='line'>3670</span>    * &lt;var>elem&lt;/var>.classList.length; // returns 2
<span class='line'>3671</span>    * &lt;var>elem&lt;/var>.classList.toggle('test2'); // returns false
<span class='line'>3672</span>    * &lt;var>elem&lt;/var>.classList.has('test2'); // returns false
<span class='line'>3673</span>    * &lt;var>elem&lt;/var>.classList.has('test'); // returns true
<span class='line'>3674</span>    * &lt;var>elem&lt;/var>.classList.remove('test');&lt;/code>
<span class='line'>3675</span>    *
<span class='line'>3676</span>    * @field
<span class='line'>3677</span>    * @type $.dom.DOMTokenList
<span class='line'>3678</span>    * @see $.dom.DOMTokenList for more details
<span class='line'>3679</span>    */</span><span class="WHIT">
<span class='line'>3680</span> </span><span class="WHIT">  </span><span class="NAME">classList</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3681</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">$.dom.DOMTokenList</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'className'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3682</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3683</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3684</span> 
<span class='line'>3685</span> </span><span class="NAME">$.dom.HTMLLinkElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3686</span> </span><span class="WHIT">  </span><span class="NAME">relList</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3687</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">$.dom.DOMTokenList</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rel'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3688</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3689</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3690</span> 
<span class='line'>3691</span> </span><span class="NAME">$.dom.HTMLAnchorElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3692</span> </span><span class="WHIT">  </span><span class="NAME">relList</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3693</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">$.dom.DOMTokenList</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rel'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3694</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3695</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3696</span> 
<span class='line'>3697</span> </span><span class="NAME">$.dom.HTMLAnchorElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3698</span> </span><span class="WHIT">  </span><span class="NAME">relList</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3699</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">$.dom.DOMTokenList</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rel'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3700</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3701</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3702</span> 
<span class='line'>3703</span> </span><span class="NAME">$.dom.HTMLAreaElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3704</span> </span><span class="WHIT">  </span><span class="NAME">relList</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3705</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">$.dom.DOMTokenList</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'rel'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3706</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3707</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3708</span> 
<span class='line'>3709</span> 
<span class='line'>3710</span> </span><span class="COMM">/**
<span class='line'>3711</span>  * Get the computed style for a property of an element.
<span class='line'>3712</span>  *
<span class='line'>3713</span>  * @param {Element} elem The element you want to get the computed style from.
<span class='line'>3714</span>  *
<span class='line'>3715</span>  * @param {String} prop The style property name you want.
<span class='line'>3716</span>  *
<span class='line'>3717</span>  * @returns {String} The computed style for the given property.
<span class='line'>3718</span>  */</span><span class="WHIT">
<span class='line'>3719</span> </span><span class="NAME">$.dom.getStyle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">prop</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3720</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">elem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3721</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3722</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3723</span> 
<span class='line'>3724</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">doc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">elem.ownerDocument</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3725</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">doc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3726</span> </span><span class="WHIT">    </span><span class="NAME">doc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3727</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3728</span> 
<span class='line'>3729</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">win</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">doc.defaultView</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3730</span> 
<span class='line'>3731</span> </span><span class="WHIT">  </span><span class="COMM">// &lt;sarcasm type=":)">TODO:&lt;/sarcasm> MSIE is unsupported for now.</span><span class="WHIT">
<span class='line'>3732</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">win</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">win.getComputedStyle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3733</span> </span><span class="WHIT">    </span><span class="NAME">cs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">win.getComputedStyle</span><span class="PUNC">(</span><span class="NAME">elem</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3734</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3735</span> 
<span class='line'>3736</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3737</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">cs</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3738</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">elem.style</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3739</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">elem.style</span><span class="PUNC">[</span><span class="NAME">prop</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3740</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3741</span> 
<span class='line'>3742</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3743</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3744</span> 
<span class='line'>3745</span> </span><span class="COMM">// Extend the global DOM object prototypes.</span><span class="WHIT">
<span class='line'>3746</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3747</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">extend_objects</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3748</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3749</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3750</span> 
<span class='line'>3751</span> </span><span class="WHIT">  </span><span class="COMM">// Improve MSIE compatibility by allowing the extension of window.Element </span><span class="WHIT">
<span class='line'>3752</span> </span><span class="WHIT">  </span><span class="COMM">// instead of window.Node.</span><span class="WHIT">
<span class='line'>3753</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">node_proto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.Node</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">window.Node.prototype</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.Element</span><span class="WHIT"> 
<span class='line'>3754</span>       </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">window.Element.prototype</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3755</span> 
<span class='line'>3756</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node_proto</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3757</span> </span><span class="WHIT">    </span><span class="NAME">$.extend</span><span class="PUNC">(</span><span class="NAME">node_proto</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$.dom.Node</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3758</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3759</span> 
<span class='line'>3760</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">globals</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Element'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Text'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Comment'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'NodeList'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'HTMLCollection'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>3761</span>   </span><span class="STRN">'NamedNodeMap'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3762</span> 
<span class='line'>3763</span> </span><span class="WHIT">  </span><span class="NAME">$.js.Array.forEach.call</span><span class="PUNC">(</span><span class="NAME">globals</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">val</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3764</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">[</span><span class="NAME">val</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3765</span> </span><span class="WHIT">      </span><span class="NAME">$.extend</span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">[</span><span class="NAME">val</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">prototype</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$.dom</span><span class="PUNC">[</span><span class="NAME">val</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3766</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3767</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3768</span> 
<span class='line'>3769</span> </span><span class="WHIT">  </span><span class="COMM">// Preferably pick KeyboardEvent, instead of the more-generic Event object.</span><span class="WHIT">
<span class='line'>3770</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">kev_proto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.KeyboardEvent</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">window.KeyboardEvent.prototype</span><span class="WHIT"> 
<span class='line'>3771</span>     </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.Event</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">window.Event.prototype</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3772</span> 
<span class='line'>3773</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">kev_proto</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3774</span> </span><span class="WHIT">    </span><span class="NAME">$.extend</span><span class="PUNC">(</span><span class="NAME">kev_proto</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$.dom.KeyboardEvent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3775</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3776</span> 
<span class='line'>3777</span> </span><span class="WHIT">  </span><span class="COMM">// The following chokes MSIE</span><span class="WHIT">
<span class='line'>3778</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">window.DOMTokenList</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">$.browser.msie</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3779</span> </span><span class="WHIT">    </span><span class="COMM">//window.DOMTokenList = $.dom.DOMTokenList;</span><span class="WHIT">
<span class='line'>3780</span> 
<span class='line'>3781</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.HTMLElement</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3782</span> </span><span class="WHIT">      </span><span class="NAME">HTMLElement.prototype.__defineGetter__</span><span class="PUNC">(</span><span class="STRN">'classList'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>3783</span>           </span><span class="NAME">$.dom.HTMLElement.classList</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3784</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3785</span> 
<span class='line'>3786</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.HTMLLinkElement</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3787</span> </span><span class="WHIT">      </span><span class="NAME">HTMLLinkElement.prototype.__defineGetter__</span><span class="PUNC">(</span><span class="STRN">'relList'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>3788</span>           </span><span class="NAME">$.dom.HTMLLinkElement.relList</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3789</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3790</span> </span><span class="WHIT">    
<span class='line'>3791</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.HTMLAnchorElement</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3792</span> </span><span class="WHIT">      </span><span class="NAME">HTMLAnchorElement.prototype.__defineGetter__</span><span class="PUNC">(</span><span class="STRN">'relList'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>3793</span>           </span><span class="NAME">$.dom.HTMLAnchorElement.relList</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3794</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3795</span> 
<span class='line'>3796</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window.HTMLAreaElement</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3797</span> </span><span class="WHIT">      </span><span class="NAME">HTMLAreaElement.prototype.__defineGetter__</span><span class="PUNC">(</span><span class="STRN">'relList'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>3798</span>           </span><span class="NAME">$.dom.HTMLAreaElement.relList</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3799</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3800</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3801</span> 
<span class='line'>3802</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">$.browser.msie</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">$.dom.EventTarget</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.attachEvent</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>3803</span>       </span><span class="NAME">document.detachEvent</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">document.addEventListener</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>3804</span>       </span><span class="PUNC">!</span><span class="NAME">document.removeEventListener</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3805</span> 
<span class='line'>3806</span> </span><span class="WHIT">    </span><span class="COMM">// MSIE does not have EventTarget (only Webkit does). As such, we extend the </span><span class="WHIT">
<span class='line'>3807</span> </span><span class="WHIT">    </span><span class="COMM">// Element object.</span><span class="WHIT">
<span class='line'>3808</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">evt</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$.dom.EventTarget</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">proto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.Element.prototype</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3809</span> 
<span class='line'>3810</span> </span><span class="WHIT">    </span><span class="NAME">proto.addEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">evt.addEventListener</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3811</span> </span><span class="WHIT">    </span><span class="NAME">proto.removeEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">evt.removeEventListener</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3812</span> 
<span class='line'>3813</span> </span><span class="WHIT">    </span><span class="COMM">// Add the methods to the window object as well.</span><span class="WHIT">
<span class='line'>3814</span> </span><span class="WHIT">    </span><span class="NAME">window.addEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">evt.addEventListener</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3815</span> </span><span class="WHIT">    </span><span class="NAME">window.removeEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">evt.removeEventListener</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3816</span> 
<span class='line'>3817</span> </span><span class="WHIT">    </span><span class="COMM">// Add the preventDefault() method to MSIE events.</span><span class="WHIT">
<span class='line'>3818</span> </span><span class="WHIT">    </span><span class="NAME">$.extend</span><span class="PUNC">(</span><span class="NAME">window.Event.prototype</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">$.dom.Event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3819</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3820</span> 
<span class='line'>3821</span> </span><span class="WHIT">  </span><span class="COMM">// Dear Microsoft, ...</span><span class="WHIT">
<span class='line'>3822</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">window.Node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3823</span> </span><span class="WHIT">    </span><span class="NAME">window.Node</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>3824</span> </span><span class="WHIT">      </span><span class="NAME">ELEMENT_NODE</span><span class="WHIT">                   </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3825</span> </span><span class="WHIT">      </span><span class="NAME">ATTRIBUTE_NODE</span><span class="WHIT">                 </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3826</span> </span><span class="WHIT">      </span><span class="NAME">TEXT_NODE</span><span class="WHIT">                      </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3827</span> </span><span class="WHIT">      </span><span class="NAME">CDATA_SECTION_NODE</span><span class="WHIT">             </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3828</span> </span><span class="WHIT">      </span><span class="NAME">ENTITY_REFERENCE_NODE</span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3829</span> </span><span class="WHIT">      </span><span class="NAME">ENTITY_NODE</span><span class="WHIT">                    </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3830</span> </span><span class="WHIT">      </span><span class="NAME">PROCESSING_INSTRUCTION_NODE</span><span class="WHIT">    </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3831</span> </span><span class="WHIT">      </span><span class="NAME">COMMENT_NODE</span><span class="WHIT">                   </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3832</span> </span><span class="WHIT">      </span><span class="NAME">DOCUMENT_NODE</span><span class="WHIT">                  </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3833</span> </span><span class="WHIT">      </span><span class="NAME">DOCUMENT_TYPE_NODE</span><span class="WHIT">             </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3834</span> </span><span class="WHIT">      </span><span class="NAME">DOCUMENT_FRAGMENT_NODE</span><span class="WHIT">         </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">11</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>3835</span> </span><span class="WHIT">      </span><span class="NAME">NOTATION_NODE</span><span class="WHIT">                  </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="WHIT">
<span class='line'>3836</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3837</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>3838</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// end of extend_objects</span><span class="WHIT">
<span class='line'>3839</span> 
<span class='line'>3840</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>3841</span> 
<span class='line'>3842</span> 
<span class='line'>3843</span> </span><span class="COMM">// vim:set spell spl=en fo=wan1croqlt tw=80 ts=2 sw=2 sts=2 sta et ai cin fenc=utf-8 ff=unix:</span><span class="WHIT">
<span class='line'>3844</span> 
<span class='line'>3845</span> </span></pre></body></html>